2022-04-10 20:29:46 -05:00
|
|
|
import { expect } from 'chai'
|
2022-03-07 16:36:22 -05:00
|
|
|
import { polyfill } from '../mod.js'
|
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
describe('Storage', () => {
|
|
|
|
const target = {}
|
2022-03-07 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05:00
|
|
|
before(() => polyfill(target))
|
2022-03-07 16:37:50 -05:00
|
|
|
|
2022-04-10 20:29:46 -05: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 16:36:22 -05:00
|
|
|
|
2022-04-10 20:29:46 -05: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 16:36:22 -05:00
|
|
|
})
|