Fixing up the tests with some refactoring

This commit is contained in:
Will Marshall
2013-12-11 15:33:57 +11:00
parent 71a5d84a1d
commit bc4f472523
7 changed files with 19 additions and 12 deletions

View File

@@ -10,14 +10,16 @@ describe 'All controllers', ->
module('Shop')
Product =
all: ->
'testy mctest'
update: ->
data: "testy mctest"
inject ($controller, $rootScope) ->
rootScope = $rootScope
scope = $rootScope.$new()
ctrl = $controller 'ProductsCtrl', {$scope: scope, Product : Product}
it 'Fetches products from Product', ->
expect(scope.products).toEqual 'testy mctest'
expect(scope.data).toEqual 'testy mctest'
#it "updates products when the changeOrderCycle event is seen", ->
#spyOn(scope, "updateProducts")

View File

@@ -21,3 +21,5 @@ describe 'OrderCycle service', ->
OrderCycle.set_order_cycle(10)
$httpBackend.flush()
expect(mockProduct.update).toHaveBeenCalled()

View File

@@ -12,4 +12,3 @@ describe 'Product service', ->
$httpBackend.expectGET("/shop/products").respond([{test : "cats"}])
products = Product.all()
$httpBackend.flush()
expect(products[0].test).toEqual "cats"