Working with ngForm and subcontrollers. Also fixing bulk order specs

This commit is contained in:
Will Marshall
2014-04-10 16:32:08 +10:00
parent 00f5d09d65
commit 5f62cb7ddb
15 changed files with 205 additions and 172 deletions

View File

@@ -7,8 +7,8 @@ describe 'Order service', ->
orderData = {
id: 3102
payment_method_id: null
bill_address: {}
ship_address: {}
bill_address: {test: "foo"}
ship_address: {test: "bar"}
shipping_methods:
7:
require_ship_address: true
@@ -26,12 +26,14 @@ describe 'Order service', ->
inject ($injector, _$httpBackend_)->
$httpBackend = _$httpBackend_
Order = $injector.get("Order")
spyOn(Order, "navigate") # Stubbing out writes to window.location
it "defaults the shipping method to the first", ->
expect(Order.order.shipping_method_id).toEqual 7
expect(Order.shippingMethod()).toEqual { require_ship_address : true, price : 0 }
it "defaults to 'same as billing' for address", ->
# This is now handled via localStorage defaults
xit "defaults to 'same as billing' for address", ->
expect(Order.order.ship_address_same_as_billing).toEqual true
it 'Tracks whether a ship address is required', ->
@@ -59,3 +61,9 @@ describe 'Order service', ->
expect(Order.preprocess().bill_address).toBe(undefined)
expect(Order.preprocess().ship_address_attributes).not.toBe(undefined)
expect(Order.preprocess().ship_address).toBe(undefined)
it "Munges the order attributes to clone ship address from bill address", ->
Order.order.ship_address_same_as_billing = false
expect(Order.preprocess().ship_address_attributes).toEqual(orderData.ship_address)
Order.order.ship_address_same_as_billing = true
expect(Order.preprocess().ship_address_attributes).toEqual(orderData.bill_address)