mirror of
https://github.com/cupcakearmy/memiens.git
synced 2024-12-22 07:56:26 +00:00
reformatted
This commit is contained in:
parent
920fbf41e5
commit
52ba538e82
39
test/main.js
39
test/main.js
@ -1,29 +1,30 @@
|
||||
const assert = require('assert')
|
||||
const {
|
||||
unlinkSync
|
||||
unlinkSync,
|
||||
} = require('fs')
|
||||
const memento = require('../').default
|
||||
const Memiens = require('../').default
|
||||
|
||||
const filename = 'test.yaml'
|
||||
const filename = './test.yaml'
|
||||
const deleteFile = () => {
|
||||
try {
|
||||
// Remove the test file
|
||||
unlinkSync(filename)
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
describe('Memento', () => {
|
||||
describe('Memiens', () => {
|
||||
|
||||
after(deleteFile)
|
||||
|
||||
describe('Basics', () => {
|
||||
deleteFile()
|
||||
it('Instantiating without existing file', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
})
|
||||
|
||||
it('Saving simple string', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
|
||||
const key = 'test'
|
||||
const value = 'ok'
|
||||
@ -34,7 +35,7 @@ describe('Memento', () => {
|
||||
})
|
||||
|
||||
describe('Preserve types', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
const key = 'key'
|
||||
|
||||
const test = (value) => {
|
||||
@ -80,12 +81,12 @@ describe('Memento', () => {
|
||||
const value = 42
|
||||
|
||||
it('Write', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
Settings.set(key, value)
|
||||
})
|
||||
|
||||
it('Read', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
assert.strictEqual(Settings.get(key), value)
|
||||
})
|
||||
})
|
||||
@ -96,18 +97,18 @@ describe('Memento', () => {
|
||||
const data = {
|
||||
a: {
|
||||
b: {
|
||||
c: [8, false]
|
||||
}
|
||||
}
|
||||
c: [8, false],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
it('Write', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
Settings.set('a.b.c', data.a.b.c)
|
||||
})
|
||||
|
||||
it('Read', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
assert.deepStrictEqual(Settings.get('a'), data.a)
|
||||
assert.deepStrictEqual(Settings.get('a.b'), data.a.b)
|
||||
assert.deepStrictEqual(Settings.get('a.b.c'), data.a.b.c)
|
||||
@ -117,16 +118,16 @@ describe('Memento', () => {
|
||||
describe('Get with initializer', () => {
|
||||
deleteFile()
|
||||
|
||||
const key = 'initialized'
|
||||
const value = true
|
||||
const key = 'initialized.nested'
|
||||
const value = 42
|
||||
|
||||
it('Getting', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
assert.strictEqual(Settings.get(key, value), value)
|
||||
})
|
||||
|
||||
it('Verify it was written', () => {
|
||||
const Settings = new memento(filename)
|
||||
const Settings = new Memiens(filename)
|
||||
assert.strictEqual(Settings.get(key), value)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user