Adding new producer modal and dereferencing shopfront

This commit is contained in:
Will Marshall
2014-06-19 14:00:37 +10:00
parent 9951f668e8
commit 7f4816c9a5
7 changed files with 43 additions and 50 deletions

View File

@@ -1,14 +1,27 @@
describe 'Product service', ->
$httpBackend = null
Product = null
Enterprises = null
product =
test: "cats"
supplier:
id: 9
beforeEach ->
module 'Darkswarm'
inject ($injector, _$httpBackend_)->
Product = $injector.get("Product")
Enterprises = $injector.get("Enterprises")
$httpBackend = _$httpBackend_
it "Fetches products from the backend on init", ->
$httpBackend.expectGET("/shop/products").respond([{test : "cats"}])
$httpBackend.expectGET("/shop/products").respond([product])
$httpBackend.flush()
expect(Product.products[0].test).toEqual "cats"
it "dereferences suppliers", ->
Enterprises.enterprises_by_id =
{id: 9, name: "test"}
$httpBackend.expectGET("/shop/products").respond([{supplier : {id: 9}}])
$httpBackend.flush()
expect(Product.products[0].supplier).toBe Enterprises.enterprises_by_id["9"]