mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Fix variant override spec
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
describe "VariantOverrides service", ->
|
||||
VariantOverrides = $httpBackend = null
|
||||
variantOverrides = [
|
||||
{id: 1, hub_id: 10, variant_id: 100, sku: "V100", price: 1, count_on_hand: 1, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
{id: 2, hub_id: 10, variant_id: 200, sku: "V200", price: 2, count_on_hand: 2, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
{id: 3, hub_id: 20, variant_id: 300, sku: "V300", price: 3, count_on_hand: 3, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
{id: 1, hub_id: 10, variant_id: 100, producer_id: 500, sku: "V100", price: 1, count_on_hand: 1, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
{id: 2, hub_id: 10, variant_id: 200, producer_id: 500, sku: "V200", price: 2, count_on_hand: 2, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
{id: 3, hub_id: 20, variant_id: 300, producer_id: 500, sku: "V300", price: 3, count_on_hand: 3, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
@@ -19,38 +19,44 @@ describe "VariantOverrides service", ->
|
||||
it "indexes variant overrides by hub_id -> variant_id", ->
|
||||
expect(VariantOverrides.variantOverrides).toEqual
|
||||
10:
|
||||
100: {id: 1, hub_id: 10, variant_id: 100, sku: "V100", price: 1, count_on_hand: 1, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: {id: 2, hub_id: 10, variant_id: 200, sku: "V200", price: 2, count_on_hand: 2, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
100: {id: 1, hub_id: 10, variant_id: 100, producer_id: 500, sku: "V100", price: 1, count_on_hand: 1, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: {id: 2, hub_id: 10, variant_id: 200, producer_id: 500, sku: "V200", price: 2, count_on_hand: 2, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
20:
|
||||
300: {id: 3, hub_id: 20, variant_id: 300, sku: "V300", price: 3, count_on_hand: 3, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
300: {id: 3, hub_id: 20, variant_id: 300, producer_id: 500, sku: "V300", price: 3, count_on_hand: 3, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
|
||||
it "ensures blank data available for some products", ->
|
||||
hubs = [{id: 10}, {id: 20}, {id: 30}]
|
||||
products = [
|
||||
{
|
||||
id: 1
|
||||
variants: [{id: 100}, {id: 200}, {id: 300}, {id: 400}, {id: 500}]
|
||||
variants: [
|
||||
{id: 100, producer_id: 1000},
|
||||
{id: 200, producer_id: 1000},
|
||||
{id: 300, producer_id: 1000},
|
||||
{id: 400, producer_id: 1000},
|
||||
{id: 500, producer_id: 1001}
|
||||
]
|
||||
}
|
||||
]
|
||||
VariantOverrides.ensureDataFor hubs, products
|
||||
expect(VariantOverrides.variantOverrides[10]).toEqual
|
||||
100: { id: 1, hub_id: 10, variant_id: 100, sku: "V100", price: 1, count_on_hand: 1, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: { id: 2, hub_id: 10, variant_id: 200, sku: "V200", price: 2, count_on_hand: 2, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
300: { hub_id: 10, variant_id: 300, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
400: { hub_id: 10, variant_id: 400, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
500: { hub_id: 10, variant_id: 500, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
100: { id: 1, hub_id: 10, variant_id: 100, producer_id: 500, sku: "V100", price: 1, count_on_hand: 1, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: { id: 2, hub_id: 10, variant_id: 200, producer_id: 500, sku: "V200", price: 2, count_on_hand: 2, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
300: { hub_id: 10, variant_id: 300, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
400: { hub_id: 10, variant_id: 400, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
500: { hub_id: 10, variant_id: 500, producer_id: 1001, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
expect(VariantOverrides.variantOverrides[20]).toEqual
|
||||
100: { hub_id: 20, variant_id: 100, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: { hub_id: 20, variant_id: 200, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
300: { id: 3, hub_id: 20, variant_id: 300, sku: "V300", price: 3, count_on_hand: 3, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
400: { hub_id: 20, variant_id: 400, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: []}
|
||||
500: { hub_id: 20, variant_id: 500, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
100: { hub_id: 20, variant_id: 100, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: { hub_id: 20, variant_id: 200, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
300: { id: 3, hub_id: 20, variant_id: 300, producer_id: 500, sku: "V300", price: 3, count_on_hand: 3, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
400: { hub_id: 20, variant_id: 400, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: []}
|
||||
500: { hub_id: 20, variant_id: 500, producer_id: 1001, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
expect(VariantOverrides.variantOverrides[30]).toEqual
|
||||
100: { hub_id: 30, variant_id: 100, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: { hub_id: 30, variant_id: 200, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
300: { hub_id: 30, variant_id: 300, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: []}
|
||||
400: { hub_id: 30, variant_id: 400, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
500: { hub_id: 30, variant_id: 500, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
100: { hub_id: 30, variant_id: 100, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
200: { hub_id: 30, variant_id: 200, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
300: { hub_id: 30, variant_id: 300, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: []}
|
||||
400: { hub_id: 30, variant_id: 400, producer_id: 1000, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
500: { hub_id: 30, variant_id: 500, producer_id: 1001, sku: null, price: null, count_on_hand: null, on_demand: null, default_stock: null, resettable: false, tag_list : '', tags: [] }
|
||||
|
||||
it "updates the IDs of variant overrides", ->
|
||||
VariantOverrides.variantOverrides[2] = {}
|
||||
|
||||
Reference in New Issue
Block a user