mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Fix shopping system spec
This commit is contained in:
@@ -19,16 +19,16 @@ describe 'Products service', ->
|
||||
beforeEach ->
|
||||
product =
|
||||
test: "cats"
|
||||
supplier:
|
||||
id: 9
|
||||
price: 11
|
||||
master: {}
|
||||
variants: []
|
||||
variants: [
|
||||
id: 1000, price: 11, supplier: {id: 9}
|
||||
]
|
||||
productWithImage =
|
||||
supplier:
|
||||
id: 9
|
||||
master: {}
|
||||
variants: []
|
||||
variants: [
|
||||
id: 1000, price: 20, supplier: {id: 9}
|
||||
]
|
||||
image: {
|
||||
large_url: 'foo.png'
|
||||
}
|
||||
@@ -79,7 +79,7 @@ describe 'Products service', ->
|
||||
it "dereferences suppliers", ->
|
||||
Shopfront.producers_by_id =
|
||||
{id: 9, name: "test"}
|
||||
$httpBackend.expectGET(endpoint).respond([{supplier : {id: 9}, master: {}}])
|
||||
$httpBackend.expectGET(endpoint).respond([product])
|
||||
$httpBackend.flush()
|
||||
expect(Products.products[0].supplier).toBe Shopfront.producers_by_id["9"]
|
||||
|
||||
@@ -96,13 +96,16 @@ describe 'Products service', ->
|
||||
expect(Products.products[0].properties[1]).toBe properties[0]
|
||||
|
||||
it "registers variants with Variants service", ->
|
||||
product.variants = [{id: 1}]
|
||||
product.variants = [{id: 1, supplier: {id: 9}}]
|
||||
$httpBackend.expectGET(endpoint).respond([product])
|
||||
$httpBackend.flush()
|
||||
expect(Products.products[0].variants[0]).toBe Variants.variants[1]
|
||||
|
||||
it "stores variant names", ->
|
||||
product.variants = [{id: 1, name_to_display: "one"}, {id: 2, name_to_display: "two"}]
|
||||
product.variants = [
|
||||
{id: 1, name_to_display: "one", supplier: {id: 9}},
|
||||
{id: 2, name_to_display: "two", supplier: {id: 9}}
|
||||
]
|
||||
$httpBackend.expectGET(endpoint).respond([product])
|
||||
$httpBackend.flush()
|
||||
expect(Products.products[0].variant_names).toEqual "one two "
|
||||
@@ -125,7 +128,9 @@ describe 'Products service', ->
|
||||
expect(Products.products[0].price).toEqual 11.00
|
||||
|
||||
it "displays the minimum variant price when the product has variants", ->
|
||||
product.variants = [{price: 22}, {price: 33}]
|
||||
product.variants = [
|
||||
{price: 22, supplier: {id: 9} }, {price: 33, supplier: {id: 9}}
|
||||
]
|
||||
$httpBackend.expectGET(endpoint).respond([product])
|
||||
$httpBackend.flush()
|
||||
expect(Products.products[0].price).toEqual 22
|
||||
|
||||
Reference in New Issue
Block a user