mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Reworking the tests for the new app
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
describe "CheckoutCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
order = null
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
order =
|
||||
id: 3102
|
||||
shipping_method_id: "7"
|
||||
ship_address_same_as_billing: true
|
||||
payment_method_id: null
|
||||
shipping_methods:
|
||||
7:
|
||||
require_ship_address: true
|
||||
price: 0.0
|
||||
|
||||
25:
|
||||
require_ship_address: false
|
||||
price: 13
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, order: order}
|
||||
|
||||
|
||||
it 'Gets the ship address automatically', ->
|
||||
expect(scope.require_ship_address).toEqual true
|
||||
|
||||
it 'Gets the current shipping price', ->
|
||||
expect(scope.shippingPrice()).toEqual 0.0
|
||||
scope.order.shipping_method_id = 25
|
||||
expect(scope.shippingPrice()).toEqual 13
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
describe 'OrderCycleCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
product_ctrl = null
|
||||
OrderCycle = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
scope = {}
|
||||
OrderCycle =
|
||||
order_cycle: "test"
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'OrderCycleCtrl', {$scope: scope, OrderCycle: OrderCycle}
|
||||
|
||||
it "puts the order cycle in scope", ->
|
||||
expect(scope.order_cycle).toEqual "test"
|
||||
@@ -6,7 +6,7 @@ describe 'All controllers', ->
|
||||
Product = null
|
||||
|
||||
beforeEach ->
|
||||
module('Shop')
|
||||
module('Darkswarm')
|
||||
Product =
|
||||
all: ->
|
||||
update: ->
|
||||
@@ -40,42 +40,8 @@ describe 'All controllers', ->
|
||||
OrderCycle = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Shop'
|
||||
module 'Darkswarm'
|
||||
scope = {}
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'OrderCycleCtrl', {$scope: scope}
|
||||
|
||||
describe "CheckoutCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
order = null
|
||||
|
||||
beforeEach ->
|
||||
module("Checkout")
|
||||
order =
|
||||
id: 3102
|
||||
shipping_method_id: "7"
|
||||
ship_address_same_as_billing: true
|
||||
payment_method_id: null
|
||||
shipping_methods:
|
||||
7:
|
||||
require_ship_address: true
|
||||
price: 0.0
|
||||
|
||||
25:
|
||||
require_ship_address: false
|
||||
price: 13
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, order: order}
|
||||
|
||||
|
||||
it 'Gets the ship address automatically', ->
|
||||
expect(scope.require_ship_address).toEqual true
|
||||
|
||||
it 'Gets the current shipping price', ->
|
||||
expect(scope.shippingPrice()).toEqual 0.0
|
||||
scope.order.shipping_method_id = 25
|
||||
expect(scope.shippingPrice()).toEqual 13
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
describe "SidebarCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
location = null
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
location =
|
||||
path: ->
|
||||
"/test"
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope
|
||||
ctrl = $controller 'SidebarCtrl', {$scope: scope, $location: location}
|
||||
scope.$apply()
|
||||
|
||||
it 'tracks the active sidebar from the $location', ->
|
||||
expect(scope.active_sidebar).toEqual "/test"
|
||||
|
||||
it 'is active when a location is set', ->
|
||||
expect(scope.active()).toEqual "active"
|
||||
|
||||
it 'is inactive no location is set', ->
|
||||
scope.active_sidebar = null
|
||||
expect(scope.active()).toEqual null
|
||||
@@ -6,8 +6,8 @@ describe 'OrderCycle service', ->
|
||||
}
|
||||
|
||||
beforeEach ->
|
||||
angular.module('Shop').value('orderCycleData', {})
|
||||
module 'Shop', ($provide)->
|
||||
angular.module('Darkswarm').value('orderCycleData', {})
|
||||
module 'Darkswarm', ($provide)->
|
||||
$provide.value "Product", mockProduct
|
||||
null # IMPORTANT
|
||||
# You must return null because module() is a bit dumb
|
||||
|
||||
@@ -3,7 +3,7 @@ describe 'Product service', ->
|
||||
Product = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Shop'
|
||||
module 'Darkswarm'
|
||||
inject ($injector, _$httpBackend_)->
|
||||
Product = $injector.get("Product")
|
||||
$httpBackend = _$httpBackend_
|
||||
|
||||
Reference in New Issue
Block a user