mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-20 00:37:26 +00:00
Use correct placeholders for VO count_on_hand
This commit is contained in:
@@ -120,3 +120,51 @@ describe "VariantOverridesCtrl", ->
|
||||
expect(scope.variantOverrides[123][2].count_on_hand).toBeNull()
|
||||
dirtyVariantOverride = DirtyVariantOverrides.dirtyVariantOverrides[123][2]
|
||||
expect(dirtyVariantOverride.count_on_hand).toBeNull()
|
||||
|
||||
describe "count on hand placeholder", ->
|
||||
beforeEach ->
|
||||
scope.variantOverrides = {123: {}}
|
||||
|
||||
describe "when variant is on demand", ->
|
||||
variant = null
|
||||
|
||||
beforeEach ->
|
||||
# Ideally, count_on_hand is blank when the variant is on demand. However, this rule is not
|
||||
# enforced.
|
||||
variant = {id: 2, on_demand: true, count_on_hand: 20, on_hand: t("on_demand")}
|
||||
|
||||
it "is 'On demand' when variant override uses producer stock settings", ->
|
||||
scope.variantOverrides[123][2] = {on_demand: null, count_on_hand: 1}
|
||||
placeholder = scope.countOnHandPlaceholder(variant, 123)
|
||||
expect(placeholder).toBe(t("on_demand"))
|
||||
|
||||
it "is 'On demand' when variant override is on demand", ->
|
||||
scope.variantOverrides[123][2] = {on_demand: true, count_on_hand: 1}
|
||||
placeholder = scope.countOnHandPlaceholder(variant, 123)
|
||||
expect(placeholder).toBe(t("js.variants.on_demand.yes"))
|
||||
|
||||
it "is blank when variant override is limited stock", ->
|
||||
scope.variantOverrides[123][2] = {on_demand: false, count_on_hand: 1}
|
||||
placeholder = scope.countOnHandPlaceholder(variant, 123)
|
||||
expect(placeholder).toBe('')
|
||||
|
||||
describe "when variant is limited stock", ->
|
||||
variant = null
|
||||
|
||||
beforeEach ->
|
||||
variant = {id: 2, on_demand: false, count_on_hand: 20, on_hand: 20}
|
||||
|
||||
it "is variant count on hand when variant override uses producer stock settings", ->
|
||||
scope.variantOverrides[123][2] = {on_demand: null, count_on_hand: 1}
|
||||
placeholder = scope.countOnHandPlaceholder(variant, 123)
|
||||
expect(placeholder).toBe(20)
|
||||
|
||||
it "is 'On demand' when variant override is on demand", ->
|
||||
scope.variantOverrides[123][2] = {on_demand: true, count_on_hand: 1}
|
||||
placeholder = scope.countOnHandPlaceholder(variant, 123)
|
||||
expect(placeholder).toBe(t("js.variants.on_demand.yes"))
|
||||
|
||||
it "is blank when variant override is limited stock", ->
|
||||
scope.variantOverrides[123][2] = {on_demand: false, count_on_hand: 1}
|
||||
placeholder = scope.countOnHandPlaceholder(variant, 123)
|
||||
expect(placeholder).toBe('')
|
||||
|
||||
Reference in New Issue
Block a user