Repository URL to install this package:
|
Version:
3.0.0 ▾
|
import 'jest'
import oneStorage from '../src'
describe('persistence', () => {
it('should be able to do a full flow (async)', async () => {
// simple data
await oneStorage.set('eh', 1)
const eh = await oneStorage.get('eh')
expect(eh).toEqual(1)
// complex data
interface Won {
eh: ['won']
}
await oneStorage.set('oneWon', { eh: ['won'] })
const oneWon = (await oneStorage.get('oneWon')) as Won
expect(oneWon.eh).toEqual(['won'])
// assert size
expect(oneStorage.length).toEqual(2)
// removing it
expect(await oneStorage.has('oneWon')).toEqual(true)
await oneStorage.remove('oneWon')
expect(await oneStorage.has('oneWon')).toEqual(false)
expect(await oneStorage.get('oneWon')).toEqual(undefined)
// assert updated size & untouched data
expect(oneStorage.length).toEqual(1)
expect(await oneStorage.has('eh')).toEqual(true)
await oneStorage.clear()
expect(oneStorage.ls.length).toEqual(0)
expect(oneStorage.inMemory.size).toEqual(0)
expect(oneStorage.length).toEqual(0)
})
it.skip('should be able to do a full flow (sync)', () => {
// @todo - need to update oneStorage or import an adapter directly
})
it.skip('should work with autobust', () => {
// @todo
})
it.skip('should stringify properly', () => {
// @todo
})
})