mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add confirmation persisting to localStorage
This commit is contained in:
parent
08a153e203
commit
0f564aa64d
@ -270,6 +270,17 @@ ConfigManager.prototype._emitUpdates = function(state){
|
||||
})
|
||||
}
|
||||
|
||||
ConfigManager.prototype.setConfirmed = function(confirmed) {
|
||||
var data = this.getData()
|
||||
data.isConfirmed = confirmed
|
||||
this.setData(data)
|
||||
}
|
||||
|
||||
ConfigManager.prototype.getConfirmed = function() {
|
||||
var data = this.getData()
|
||||
return ('isConfirmed' in data) && data.isConfirmed
|
||||
}
|
||||
|
||||
|
||||
function loadData() {
|
||||
|
||||
|
@ -4,11 +4,41 @@ var configManager
|
||||
|
||||
describe('config-manager', function() {
|
||||
|
||||
before(function() {
|
||||
beforeEach(function() {
|
||||
window.localStorage = {} // Hacking localStorage support into JSDom
|
||||
configManager = new ConfigManager()
|
||||
})
|
||||
|
||||
describe('confirmation', function() {
|
||||
|
||||
describe('#getConfirmed', function() {
|
||||
it('should return false if no previous key exists', function() {
|
||||
var result = configManager.getConfirmed()
|
||||
assert.ok(!result)
|
||||
})
|
||||
})
|
||||
|
||||
describe('#setConfirmed', function() {
|
||||
it('should make getConfirmed return true once set', function() {
|
||||
configManager.setConfirmed(true)
|
||||
var result = configManager.getConfirmed()
|
||||
assert.equal(result, true)
|
||||
})
|
||||
|
||||
it('should be able to set false', function() {
|
||||
configManager.setConfirmed(false)
|
||||
var result = configManager.getConfirmed()
|
||||
assert.equal(result, false)
|
||||
})
|
||||
|
||||
it('should persist to local storage', function() {
|
||||
configManager.setConfirmed(true)
|
||||
var data = configManager.getData()
|
||||
assert.equal(data.isConfirmed, true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('#setConfig', function() {
|
||||
window.localStorage = {} // Hacking localStorage support into JSDom
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user