mock-dom-storage
v1.0.0
Published
localStorage or sessionStorage mock
Downloads
64
Readme
mock-dom-storage
An in-memory implementation of the Storage API, for testing!
var localStorage = MockDomStorage()
localStorage.setItem('thing', 'value')
localStorage.getItem('thing') // => 'value'
localStorage.getItem('unknown') // => null
localStorage.length // => 1
localStorage.setItem('hello', 'world')
localStorage.setItem('name', 'person')
localStorage.length // => 3
api
var mockStorage = require('mock-dom-storage')
var storage = mockStorage()
The resulting object should, on the surface, be identical to sessionStorage or localStorage.
storage
storage.getItem(key)
storage.setItem(key, val)
storage.removeItem(key)
storage.clear()
storage.key(index)
storage.length
install
Install using npm
npm install mock-dom-storage