mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Finishing off the merge with localStorage refactoring with sekrets
This commit is contained in:
@@ -5,11 +5,13 @@ describe 'Order service', ->
|
||||
Navigation = null
|
||||
flash = null
|
||||
storage = null
|
||||
scope = null
|
||||
|
||||
beforeEach ->
|
||||
orderData =
|
||||
id: 3102
|
||||
payment_method_id: null
|
||||
email: "test@test.com"
|
||||
bill_address:
|
||||
test: "foo"
|
||||
firstname: "Robert"
|
||||
@@ -35,10 +37,12 @@ describe 'Order service', ->
|
||||
angular.module('Darkswarm').value('order', orderData)
|
||||
module 'Darkswarm'
|
||||
|
||||
inject ($injector, _$httpBackend_, _storage_)->
|
||||
inject ($injector, _$httpBackend_, _storage_, $rootScope)->
|
||||
$httpBackend = _$httpBackend_
|
||||
storage = _storage_
|
||||
Order = $injector.get("Order")
|
||||
scope = $rootScope.$new()
|
||||
scope.Order = Order
|
||||
Navigation = $injector.get("Navigation")
|
||||
flash = $injector.get("flash")
|
||||
spyOn(Navigation, "go") # Stubbing out writes to window.location
|
||||
@@ -58,6 +62,18 @@ describe 'Order service', ->
|
||||
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}"
|
||||
expect(localStorage.getItem("#{prefix}_email")).toMatch "test@test.com"
|
||||
|
||||
it "does not store secrets in local storage", ->
|
||||
Order.secrets =
|
||||
card_number: "superfuckingsecret"
|
||||
Order.bindFieldsToLocalStorage(scope)
|
||||
keys = (localStorage.key(i) for i in [0..localStorage.length])
|
||||
for key in keys
|
||||
expect(localStorage.getItem(key)).not.toMatch Order.secrets.card_number
|
||||
|
||||
describe "with shipping method", ->
|
||||
beforeEach ->
|
||||
|
||||
Reference in New Issue
Block a user