mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Adding a current user service, refactoring various consequences of this change:
This commit is contained in:
@@ -5,6 +5,7 @@ describe "CheckoutCtrl", ->
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
angular.module('Darkswarm').value('user', {})
|
||||
Order = {
|
||||
submit: ->
|
||||
navigate: ->
|
||||
|
||||
@@ -12,11 +12,3 @@ describe "SidebarCtrl", ->
|
||||
scope = $rootScope
|
||||
ctrl = $controller 'SidebarCtrl', {$scope: scope, $location: location}
|
||||
scope.$apply()
|
||||
|
||||
it 'is active when a location is set', ->
|
||||
expect(scope.active()).toEqual true
|
||||
|
||||
it 'is inactive no location is set', ->
|
||||
location.path = ->
|
||||
null
|
||||
expect(scope.active()).toEqual false
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
describe "Sidebar", ->
|
||||
location = null
|
||||
Sidebar = null
|
||||
Navigation = null
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
inject (_Sidebar_, $location, _Navigation_) ->
|
||||
Sidebar = _Sidebar_
|
||||
Navigation = _Navigation_
|
||||
location = $location
|
||||
Sidebar.paths = ["/test", "/frogs"]
|
||||
|
||||
|
||||
it 'is active when a location in paths is set', ->
|
||||
spyOn(location, "path").andReturn "/test"
|
||||
expect(Sidebar.active()).toEqual true
|
||||
|
||||
it 'is inactive if location is set', ->
|
||||
spyOn(location, "path").andReturn null
|
||||
expect(Sidebar.active()).toEqual false
|
||||
|
||||
describe "Toggling on/off", ->
|
||||
it 'toggles the current sidebar path', ->
|
||||
expect(Sidebar.active()).toEqual false
|
||||
Navigation.path = "/frogs"
|
||||
Sidebar.toggle()
|
||||
expect(Sidebar.active()).toEqual true
|
||||
|
||||
it 'If current navigation path is not in the sidebar, it toggles the first sidebar path', ->
|
||||
Navigation.path = "/donkeys"
|
||||
spyOn(Navigation, 'navigate')
|
||||
Sidebar.toggle()
|
||||
expect(Navigation.navigate).toHaveBeenCalledWith("/test")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user