mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-05 07:19:14 +00:00
Reworking the tests for the new app
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
describe "CheckoutCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
order = null
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
describe 'OrderCycleCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
product_ctrl = null
|
||||
OrderCycle = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
scope = {}
|
||||
OrderCycle =
|
||||
order_cycle: "test"
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'OrderCycleCtrl', {$scope: scope, OrderCycle: OrderCycle}
|
||||
|
||||
it "puts the order cycle in scope", ->
|
||||
expect(scope.order_cycle).toEqual "test"
|
||||
@@ -0,0 +1,47 @@
|
||||
describe 'All controllers', ->
|
||||
describe 'ProductsCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
Product = null
|
||||
|
||||
beforeEach ->
|
||||
module('Darkswarm')
|
||||
Product =
|
||||
all: ->
|
||||
update: ->
|
||||
data: "testy mctest"
|
||||
OrderCycle =
|
||||
order_cycle: {}
|
||||
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'ProductsCtrl', {$scope: scope, Product: Product, OrderCycle: OrderCycle}
|
||||
|
||||
it 'fetches products from Product', ->
|
||||
expect(scope.data).toEqual 'testy mctest'
|
||||
|
||||
describe "determining the price to display for a product", ->
|
||||
it "displays the product price when the product does not have variants", ->
|
||||
product = {variants: [], price: 12.34}
|
||||
expect(scope.productPrice(product)).toEqual 12.34
|
||||
|
||||
it "displays the minimum variant price when the product has variants", ->
|
||||
product =
|
||||
price: 11
|
||||
variants: [{price: 22}, {price: 33}]
|
||||
expect(scope.productPrice(product)).toEqual 22
|
||||
|
||||
describe 'OrderCycleCtrl', ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
event = null
|
||||
product_ctrl = null
|
||||
OrderCycle = null
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
scope = {}
|
||||
inject ($controller) ->
|
||||
scope = {}
|
||||
ctrl = $controller 'OrderCycleCtrl', {$scope: scope}
|
||||
@@ -0,0 +1,24 @@
|
||||
describe "SidebarCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
location = null
|
||||
|
||||
beforeEach ->
|
||||
module("Darkswarm")
|
||||
location =
|
||||
path: ->
|
||||
"/test"
|
||||
inject ($controller, $rootScope) ->
|
||||
scope = $rootScope
|
||||
ctrl = $controller 'SidebarCtrl', {$scope: scope, $location: location}
|
||||
scope.$apply()
|
||||
|
||||
it 'tracks the active sidebar from the $location', ->
|
||||
expect(scope.active_sidebar).toEqual "/test"
|
||||
|
||||
it 'is active when a location is set', ->
|
||||
expect(scope.active()).toEqual "active"
|
||||
|
||||
it 'is inactive no location is set', ->
|
||||
scope.active_sidebar = null
|
||||
expect(scope.active()).toEqual null
|
||||
Reference in New Issue
Block a user