mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
Basics in place, about to rework karma config
This commit is contained in:
@@ -5,30 +5,7 @@ describe "CheckoutCtrl", ->
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
order =
|
||||
id: 3102
|
||||
shipping_method_id: "7"
|
||||
ship_address_same_as_billing: true
|
||||
payment_method_id: null
|
||||
shipping_methods:
|
||||
7:
|
||||
require_ship_address: true
|
||||
price: 0.0
|
||||
|
||||
25:
|
||||
require_ship_address: false
|
||||
price: 13
|
||||
order = {}
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, order: order}
|
||||
|
||||
|
||||
it 'Gets the ship address automatically', ->
|
||||
expect(scope.require_ship_address).toEqual true
|
||||
|
||||
it 'Gets the current shipping price', ->
|
||||
expect(scope.shippingPrice()).toEqual 0.0
|
||||
scope.order.shipping_method_id = 25
|
||||
expect(scope.shippingPrice()).toEqual 13
|
||||
|
||||
|
||||
ctrl = $controller 'CheckoutCtrl', {$scope: scope, Order: order}
|
||||
|
||||
@@ -39,6 +39,6 @@ describe 'OrderCycle service', ->
|
||||
it "tells us when no order cycle is selected", ->
|
||||
OrderCycle.order_cycle = null
|
||||
expect(OrderCycle.selected()).toEqual false
|
||||
OrderCycle.order_cycle = {test: "blah"}
|
||||
OrderCycle.order_cycle = {orders_close_at: "10 days ago"}
|
||||
expect(OrderCycle.selected()).toEqual true
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
describe 'Order service', ->
|
||||
Order = null
|
||||
orderData = null
|
||||
|
||||
beforeEach ->
|
||||
orderData = {
|
||||
id: 3102
|
||||
payment_method_id: null
|
||||
shipping_methods:
|
||||
7:
|
||||
require_ship_address: true
|
||||
price: 0.0
|
||||
|
||||
25:
|
||||
require_ship_address: false
|
||||
price: 13
|
||||
payment_methods:
|
||||
99:
|
||||
test: "foo"
|
||||
}
|
||||
angular.module('Darkswarm').value('order', orderData)
|
||||
module 'Darkswarm'
|
||||
inject ($injector)->
|
||||
Order = $injector.get("Order")
|
||||
|
||||
it "defaults the shipping method to the first", ->
|
||||
expect(Order.shipping_method_id).toEqual 7
|
||||
expect(Order.shippingMethod()).toEqual { require_ship_address : true, price : 0 }
|
||||
|
||||
it "defaults to 'same as billing' for address", ->
|
||||
expect(Order.ship_address_same_as_billing).toEqual true
|
||||
|
||||
it 'Tracks whether a ship address is required', ->
|
||||
expect(Order.requireShipAddress()).toEqual true
|
||||
Order.shipping_method_id = 25
|
||||
expect(Order.requireShipAddress()).toEqual false
|
||||
|
||||
it 'Gets the current shipping price', ->
|
||||
expect(Order.shippingPrice()).toEqual 0.0
|
||||
Order.shipping_method_id = 25
|
||||
expect(Order.shippingPrice()).toEqual 13
|
||||
|
||||
it 'Gets the current payment method', ->
|
||||
expect(Order.paymentMethod()).toEqual null
|
||||
Order.payment_method_id = 99
|
||||
expect(Order.paymentMethod()).toEqual {test: "foo"}
|
||||
|
||||
Reference in New Issue
Block a user