mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Major refactoring
This commit is contained in:
@@ -2,7 +2,8 @@ describe "AccordionCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
CurrentHubMock =
|
||||
id: 1
|
||||
hub:
|
||||
id: 1
|
||||
|
||||
beforeEach ->
|
||||
module "Darkswarm"
|
||||
|
||||
@@ -9,7 +9,8 @@ describe "HubNodeCtrl", ->
|
||||
scope =
|
||||
hub: {}
|
||||
CurrentHub =
|
||||
id: 99
|
||||
hub:
|
||||
id: 99
|
||||
|
||||
inject ($controller, $location)->
|
||||
ctrl = $controller 'HubNodeCtrl', {$scope: scope, CurrentHub: CurrentHub, $location : $location}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
describe "Enterprises service", ->
|
||||
Enterprises = null
|
||||
CurrentHubMock = {}
|
||||
enterprises = [
|
||||
{id: 1, type: "hub", producers: [{id: 2}]},
|
||||
{id: 2, type: "producer", hubs: [{id: 1}]},
|
||||
@@ -7,6 +8,9 @@ describe "Enterprises service", ->
|
||||
]
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
module ($provide)->
|
||||
$provide.value "CurrentHub", CurrentHubMock
|
||||
null
|
||||
angular.module('Darkswarm').value('enterprises', enterprises)
|
||||
|
||||
inject ($injector)->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
describe "Hubs service", ->
|
||||
Hubs = null
|
||||
Enterprises = null
|
||||
CurrentHubMock = {}
|
||||
hubs = [
|
||||
{
|
||||
id: 2
|
||||
@@ -26,6 +27,9 @@ describe "Hubs service", ->
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
angular.module('Darkswarm').value('enterprises', hubs)
|
||||
module ($provide)->
|
||||
$provide.value "CurrentHub", CurrentHubMock
|
||||
null
|
||||
inject ($injector)->
|
||||
Enterprises = $injector.get("Enterprises")
|
||||
Hubs = $injector.get("Hubs")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
describe "Hubs service", ->
|
||||
OfnMap = null
|
||||
CurrentHubMock = {}
|
||||
enterprises = [
|
||||
{
|
||||
id: 2
|
||||
@@ -12,6 +13,9 @@ describe "Hubs service", ->
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
angular.module('Darkswarm').value('enterprises', enterprises)
|
||||
module ($provide)->
|
||||
$provide.value "CurrentHub", CurrentHubMock
|
||||
null
|
||||
inject ($injector)->
|
||||
OfnMap = $injector.get("OfnMap")
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ describe 'Order service', ->
|
||||
storage = null
|
||||
scope = null
|
||||
CurrentHubMock =
|
||||
id: 1
|
||||
hub:
|
||||
id: 1
|
||||
FlashLoaderMock =
|
||||
loadFlash: (arg)->
|
||||
|
||||
@@ -66,13 +67,13 @@ describe 'Order service', ->
|
||||
spyOn(storage, "bind")
|
||||
Order.fieldsToBind = ["testy"]
|
||||
Order.bindFieldsToLocalStorage({})
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}#{CurrentHubMock.id}"
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}#{CurrentHubMock.hub.id}"
|
||||
expect(storage.bind).toHaveBeenCalledWith({}, "Order.order.testy", {storeName: "#{prefix}_testy"})
|
||||
expect(storage.bind).toHaveBeenCalledWith({}, "Order.ship_address_same_as_billing", {storeName: "#{prefix}_sameasbilling", defaultValue: true})
|
||||
|
||||
it "binds order to local storage", ->
|
||||
Order.bindFieldsToLocalStorage(scope)
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}#{CurrentHubMock.id}"
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}#{CurrentHubMock.hub.id}"
|
||||
expect(localStorage.getItem("#{prefix}_email")).toMatch "test@test.com"
|
||||
|
||||
it "does not store secrets in local storage", ->
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
describe "Producers service", ->
|
||||
Producers = null
|
||||
Enterprises = null
|
||||
CurrentHubMock =
|
||||
hub:
|
||||
id: 1
|
||||
enterprises = [
|
||||
{is_primary_producer: true}
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
module ($provide)->
|
||||
$provide.value "CurrentHub", CurrentHubMock
|
||||
null
|
||||
angular.module('Darkswarm').value('enterprises', enterprises)
|
||||
inject ($injector)->
|
||||
Producers = $injector.get("Producers")
|
||||
|
||||
@@ -2,6 +2,7 @@ describe 'Product service', ->
|
||||
$httpBackend = null
|
||||
Product = null
|
||||
Enterprises = null
|
||||
CurrentHubMock = {}
|
||||
product =
|
||||
test: "cats"
|
||||
supplier:
|
||||
@@ -9,6 +10,9 @@ describe 'Product service', ->
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
module ($provide)->
|
||||
$provide.value "CurrentHub", CurrentHubMock
|
||||
null
|
||||
inject ($injector, _$httpBackend_)->
|
||||
Product = $injector.get("Product")
|
||||
Enterprises = $injector.get("Enterprises")
|
||||
|
||||
Reference in New Issue
Block a user