mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-14 04:04:23 +00:00
Reworking the JS specs
This commit is contained in:
@@ -19,14 +19,3 @@ describe "HubNodeCtrl", ->
|
||||
expect(scope.current()).toEqual false
|
||||
scope.hub = {id: 99}
|
||||
expect(scope.current()).toEqual true
|
||||
|
||||
it "knows whether selecting this hub will empty the cart", ->
|
||||
CurrentHub.id = undefined
|
||||
expect(scope.emptiesCart()).toEqual false
|
||||
|
||||
CurrentHub.id = 99
|
||||
scope.hub.id = 99
|
||||
expect(scope.emptiesCart()).toEqual false
|
||||
|
||||
scope.hub.id = 1
|
||||
expect(scope.emptiesCart()).toEqual true
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
describe "ProductNodeCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
product =
|
||||
id: 99
|
||||
price: 10.00
|
||||
variants: []
|
||||
|
||||
beforeEach ->
|
||||
module('Darkswarm')
|
||||
inject ($controller) ->
|
||||
scope =
|
||||
product: product
|
||||
ctrl = $controller 'ProductNodeCtrl', {$scope: scope}
|
||||
|
||||
describe "determining the price to display for a product", ->
|
||||
it "displays the product price when the product does not have variants", ->
|
||||
expect(scope.price()).toEqual 10.00
|
||||
|
||||
it "displays the minimum variant price when the product has variants", ->
|
||||
scope.product =
|
||||
price: 11
|
||||
variants: [{price: 22}, {price: 33}]
|
||||
expect(scope.price()).toEqual 22
|
||||
@@ -1,47 +1,21 @@
|
||||
describe 'All controllers', ->
|
||||
describe 'ProductsCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
Product = null
|
||||
describe 'ProductsCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
Product = null
|
||||
|
||||
beforeEach ->
|
||||
module('Darkswarm')
|
||||
Product =
|
||||
all: ->
|
||||
update: ->
|
||||
data: "testy mctest"
|
||||
OrderCycle =
|
||||
order_cycle: {}
|
||||
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'ProductsCtrl', {$scope: scope, Product: Product, OrderCycle: OrderCycle}
|
||||
|
||||
it 'fetches products from Product', ->
|
||||
expect(scope.data).toEqual 'testy mctest'
|
||||
|
||||
describe "determining the price to display for a product", ->
|
||||
it "displays the product price when the product does not have variants", ->
|
||||
product = {variants: [], price: 12.34}
|
||||
expect(scope.productPrice(product)).toEqual 12.34
|
||||
|
||||
it "displays the minimum variant price when the product has variants", ->
|
||||
product =
|
||||
price: 11
|
||||
variants: [{price: 22}, {price: 33}]
|
||||
expect(scope.productPrice(product)).toEqual 22
|
||||
|
||||
describe 'OrderCycleCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
product_ctrl = null
|
||||
OrderCycle = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
beforeEach ->
|
||||
module('Darkswarm')
|
||||
Product =
|
||||
all: ->
|
||||
update: ->
|
||||
data: "testy mctest"
|
||||
OrderCycle =
|
||||
order_cycle: {}
|
||||
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'OrderCycleCtrl', {$scope: scope}
|
||||
ctrl = $controller 'ProductsCtrl', {$scope: scope, Product: Product, OrderCycle: OrderCycle}
|
||||
|
||||
it 'fetches products from Product', ->
|
||||
expect(scope.data).toEqual 'testy mctest'
|
||||
|
||||
Reference in New Issue
Block a user