mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-19 00:27:25 +00:00
Cart item total reflects total number of items in the cart
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
describe 'Cart service', ->
|
||||
Cart = null
|
||||
Variants = null
|
||||
variant = {id: 1}
|
||||
order = {
|
||||
line_items: [
|
||||
variant: variant
|
||||
]
|
||||
}
|
||||
variant = null
|
||||
order = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
variant = {id: 1}
|
||||
order = {
|
||||
line_items: [
|
||||
variant: variant
|
||||
]
|
||||
}
|
||||
angular.module('Darkswarm').value('currentOrder', order)
|
||||
inject ($injector)->
|
||||
Variants = $injector.get("Variants")
|
||||
@@ -23,10 +25,15 @@ describe 'Cart service', ->
|
||||
|
||||
it "creates and backreferences new line items if necessary", ->
|
||||
Cart.register_variant(v2 = {id: 2})
|
||||
expect(Cart.line_items[1].variant).toBe v2
|
||||
expect(Cart.line_items[1].variant.line_item).toBe Cart.line_items[1]
|
||||
expect(Cart.line_items[1].variant).toBe v2
|
||||
expect(Cart.line_items[1].variant.line_item).toBe Cart.line_items[1]
|
||||
|
||||
it "returns a list of items actually in the cart", ->
|
||||
expect(Cart.line_items_present()).toEqual []
|
||||
order.line_items[0].quantity = 1
|
||||
expect(Cart.line_items_present().length).toEqual 1
|
||||
expect(Cart.line_items_present().length).toEqual
|
||||
|
||||
it "sums the quantity of each line item for cart total", ->
|
||||
expect(Cart.line_items_present()).toEqual []
|
||||
order.line_items[0].quantity = 2
|
||||
expect(Cart.total_item_count()).toEqual 2
|
||||
|
||||
Reference in New Issue
Block a user