mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
Display extended variant name in quick cart
This commit is contained in:
@@ -6,7 +6,10 @@ describe 'Cart service', ->
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
variant = {id: 1}
|
||||
variant =
|
||||
id: 1
|
||||
name_to_display: 'name'
|
||||
product_name: 'name'
|
||||
order = {
|
||||
line_items: [
|
||||
variant: variant
|
||||
@@ -23,6 +26,9 @@ describe 'Cart service', ->
|
||||
it "registers variants with the Variants service", ->
|
||||
expect(Variants.variants[1]).toBe variant
|
||||
|
||||
it "generates extended variant names", ->
|
||||
expect(Cart.line_items[0].variant.extended_name).toEqual "name"
|
||||
|
||||
it "creates and backreferences new line items if necessary", ->
|
||||
Cart.register_variant(v2 = {id: 2})
|
||||
expect(Cart.line_items[1].variant).toBe v2
|
||||
@@ -37,3 +43,23 @@ describe 'Cart service', ->
|
||||
expect(Cart.line_items_present()).toEqual []
|
||||
order.line_items[0].quantity = 2
|
||||
expect(Cart.total_item_count()).toEqual 2
|
||||
|
||||
describe "generating an extended variant name", ->
|
||||
it "returns the product name when it is the same as the variant name", ->
|
||||
variant = {product_name: 'product_name', name_to_display: 'product_name'}
|
||||
expect(Cart.extendedVariantName(variant)).toEqual "product_name"
|
||||
|
||||
describe "when the product name and the variant name differ", ->
|
||||
it "returns a combined name when there is no options text", ->
|
||||
variant =
|
||||
product_name: 'product_name'
|
||||
name_to_display: 'name_to_display'
|
||||
expect(Cart.extendedVariantName(variant)).toEqual "product_name - name_to_display"
|
||||
|
||||
it "returns a combined name when there is some options text", ->
|
||||
variant =
|
||||
product_name: 'product_name'
|
||||
name_to_display: 'name_to_display'
|
||||
options_text: 'options_text'
|
||||
|
||||
expect(Cart.extendedVariantName(variant)).toEqual "product_name - name_to_display (options_text)"
|
||||
|
||||
Reference in New Issue
Block a user