/**
* Test Dependencies
*/
import './helper.js'
import chai from 'chai'
const expect = chai.expect
import sinonChai from 'sinon-chai'
chai.use(sinonChai)
import { Datastore } from '../src/datastore.js'
const datastore = new Datastore()
describe('Datastore', () => {
describe('#set', () => {
it('"/a", true', async () => {
await datastore.set('/a', true)
// const result = datastore._root['a']
const result = datastore.get('/a')
expect(result).to.equal(true)
})
it('"/a/b", true', async () => {
await datastore.set('/a/b', true)
// const result = datastore._root['a']['b']
const result = datastore.get('/a/b')
expect(result).to.equal(true)
})
it('"/a/b/c", true', async () => {
await datastore.set('/a/b/c', true)
// const result = datastore._root['a']['b']['c']
const result = datastore.get('/a/b/c')
expect(result).to.equal(true)
})
})
describe('#delete', () => {
it('"/a"', async () => {
await datastore.set('/a', true)
await datastore.delete('/a')
// const result = datastore._root
const result = datastore.get('/a')
expect(result).not.to.exist
})
it('"/a/b"', async () => {
await datastore.set('/a/b', true)
await datastore.delete('/a/b')
// const result = datastore._root
const result = datastore.get('/a')
expect(result).not.to.exist
})
it('"/a/b/c"', async () => {
await datastore.set('/a/b/c', true)
await datastore.delete('/a/b/c')
// const result = datastore._root
const result = datastore.get('/a')
expect(result).not.to.exist
})
it('"/a2"', async () => {
await datastore.set('/a1', true)
await datastore.set('/a2', true)
await datastore.delete('/a2')
// const result = datastore._root
const result = datastore.get('/a1')
expect(result).to.eql(true)
})
})
})