mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-25 01:23:23 +00:00
Getting the test framework set up for Angular, setting up a products fetch stub
This commit is contained in:
@@ -754,4 +754,4 @@ describe 'OrderCycle services', ->
|
||||
expect(data.incoming_exchanges[0].enterprise_fees).toBeUndefined()
|
||||
expect(data.outgoing_exchanges[0].enterprise_fees).toBeUndefined()
|
||||
expect(data.incoming_exchanges[0].enterprise_fee_ids).toEqual [1, 2]
|
||||
expect(data.outgoing_exchanges[0].enterprise_fee_ids).toEqual [3, 4]
|
||||
expect(data.outgoing_exchanges[0].enterprise_fee_ids).toEqual [3, 4]
|
||||
|
||||
15
spec/javascripts/unit/product_spec.js.coffee
Normal file
15
spec/javascripts/unit/product_spec.js.coffee
Normal file
@@ -0,0 +1,15 @@
|
||||
describe 'Shop services', ->
|
||||
$httpBackend = null
|
||||
Product = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Shop'
|
||||
inject ($injector, _$httpBackend_)->
|
||||
Product = $injector.get("Product")
|
||||
$httpBackend = _$httpBackend_
|
||||
|
||||
it "Fetches products from the backend", ->
|
||||
$httpBackend.expectGET("/shop/products").respond([{test : "cats"}])
|
||||
products = Product.all()
|
||||
$httpBackend.flush()
|
||||
expect(products[0].test).toEqual "cats"
|
||||
18
spec/javascripts/unit/shop_spec.js.coffee
Normal file
18
spec/javascripts/unit/shop_spec.js.coffee
Normal file
@@ -0,0 +1,18 @@
|
||||
describe 'Shop controllers', ->
|
||||
describe 'ProductsCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
Product = null
|
||||
|
||||
beforeEach ->
|
||||
module('Shop')
|
||||
scope = {}
|
||||
Product =
|
||||
all: ->
|
||||
'testy mctest'
|
||||
inject ($controller) ->
|
||||
ctrl = $controller 'ProductsCtrl', {$scope: scope, Product : Product}
|
||||
|
||||
it 'Fetches products from Product', ->
|
||||
expect(scope.products).toEqual 'testy mctest'
|
||||
Reference in New Issue
Block a user