1 | const
|
2 | fs = require('fs'),
|
3 | path = require('path'),
|
4 | { expect } = require('chai'),
|
5 | Datastore = require('../src/Datastore')
|
6 |
|
7 | const root = path.dirname(__dirname)
|
8 |
|
9 | describe('testing datastore creation', () => {
|
10 | describe('new Datastore(\'test.db\')', () => {
|
11 | it('should create test.db based on string filename', () => {
|
12 | let datastore = Datastore.create('test.db')
|
13 | return datastore.load()
|
14 | .then(() => {
|
15 | fs.unlinkSync(
|
16 | path.join(root, 'test.db')
|
17 | )
|
18 | })
|
19 | })
|
20 | })
|
21 |
|
22 | describe('new Datastore({ filename: \'test.db\' })', () => {
|
23 | it('sould create test.db based on object parameters', () => {
|
24 | let datastore = Datastore.create({ filename: 'test.db' })
|
25 | return datastore.load()
|
26 | .then(() => {
|
27 | fs.unlinkSync(
|
28 | path.join(root, 'test.db')
|
29 | )
|
30 | })
|
31 | })
|
32 | })
|
33 |
|
34 | describe('new Datastore()', () => {
|
35 | it('should create in memory only database', (done) => {
|
36 | let datastore = Datastore.create()
|
37 | expect(datastore.__original.inMemoryOnly).to.equal(true)
|
38 | done()
|
39 | })
|
40 | })
|
41 | })
|