mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-18 04:39:14 +00:00
Merge branch 'master' into bom
This commit is contained in:
@@ -466,6 +466,35 @@ describe "AdminProductEditCtrl", ->
|
||||
expect(scope.variantUnitValue(product, variant)).toEqual null
|
||||
|
||||
|
||||
describe "updating the product on hand count", ->
|
||||
it "updates when product is not available on demand", ->
|
||||
spyOn(scope, "onHand").andReturn 123
|
||||
product = {on_demand: false}
|
||||
scope.updateOnHand(product)
|
||||
expect(product.on_hand).toEqual 123
|
||||
|
||||
it "updates when product's variants are not available on demand", ->
|
||||
spyOn(scope, "onHand").andReturn 123
|
||||
product = {on_demand: false, variants: [{on_demand: false}]}
|
||||
scope.updateOnHand(product)
|
||||
expect(product.on_hand).toEqual 123
|
||||
|
||||
it "does nothing when the product is available on demand", ->
|
||||
product = {on_demand: true}
|
||||
scope.updateOnHand(product)
|
||||
expect(product.on_hand).toBeUndefined()
|
||||
|
||||
it "does nothing when one of the variants is available on demand", ->
|
||||
product =
|
||||
on_demand: false
|
||||
variants: [
|
||||
{on_demand: false, on_hand: 10}
|
||||
{on_demand: true, on_hand: Infinity}
|
||||
]
|
||||
scope.updateOnHand(product)
|
||||
expect(product.on_hand).toBeUndefined()
|
||||
|
||||
|
||||
describe "getting on_hand counts when products have variants", ->
|
||||
p1 = undefined
|
||||
p2 = undefined
|
||||
@@ -526,6 +555,24 @@ describe "AdminProductEditCtrl", ->
|
||||
expect(scope.onHand(not_variants: [])).toEqual "error"
|
||||
|
||||
|
||||
describe "determining whether a product has variants that are available on demand", ->
|
||||
it "returns true when at least one variant does", ->
|
||||
product =
|
||||
variants: [
|
||||
{on_demand: false}
|
||||
{on_demand: true}
|
||||
]
|
||||
expect(scope.hasOnDemandVariants(product)).toBe(true)
|
||||
|
||||
it "returns false otherwise", ->
|
||||
product =
|
||||
variants: [
|
||||
{on_demand: false}
|
||||
{on_demand: false}
|
||||
]
|
||||
expect(scope.hasOnDemandVariants(product)).toBe(false)
|
||||
|
||||
|
||||
describe "submitting products to be updated", ->
|
||||
describe "packing products", ->
|
||||
it "extracts variant_unit_with_scale into variant_unit and variant_unit_scale", ->
|
||||
|
||||
Reference in New Issue
Block a user