2022-04-11 01:29:46 +00:00
|
|
|
import { expect } from 'chai'
|
2022-03-07 21:36:22 +00:00
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
describe('Storage', () => {
|
|
|
|
const target = {}
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
before(() => polyfill(target))
|
2022-03-07 21:37:50 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Includes Storage functionality', () => {
|
|
|
|
expect(target).to.have.property('Storage').that.is.a('function')
|
|
|
|
expect(target).to.have.property('localStorage').that.is.an('object')
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
|
2022-04-11 01:29:46 +00:00
|
|
|
it('Supports Storage methods', () => {
|
|
|
|
expect(target.localStorage.setItem('hello', 'world')).to.equal(undefined)
|
|
|
|
expect(target.localStorage.getItem('hello')).to.equal('world')
|
|
|
|
expect(target.localStorage.key(0)).to.equal('hello')
|
|
|
|
expect(target.localStorage.key(1)).to.equal(null)
|
|
|
|
expect(target.localStorage.length).to.equal(1)
|
|
|
|
expect(target.localStorage.setItem('world', 'hello')).to.equal(undefined)
|
|
|
|
expect(target.localStorage.key(1)).to.equal('world')
|
|
|
|
expect(target.localStorage.key(2)).to.equal(null)
|
|
|
|
expect(target.localStorage.length).to.equal(2)
|
|
|
|
expect(target.localStorage.removeItem('hello')).to.equal(undefined)
|
|
|
|
expect(target.localStorage.key(0)).to.equal('world')
|
|
|
|
expect(target.localStorage.key(1)).to.equal(null)
|
|
|
|
expect(target.localStorage.length).to.equal(1)
|
|
|
|
expect(target.localStorage.clear()).to.equal(undefined)
|
|
|
|
expect(target.localStorage.key(0)).to.equal(null)
|
|
|
|
expect(target.localStorage.length).to.equal(0)
|
|
|
|
})
|
2022-03-07 21:36:22 +00:00
|
|
|
})
|