UNPKG

730 BJavaScriptView Raw
1const {expect} = require('chai'),
2 Datastore = require('../lib/Datastore');
3
4describe('Insert', () => {
5 let documents = [
6 { name: 'first document' },
7 { name: 'second document' },
8 { name: 'third document' }
9 ];
10
11 describe(`single`, () => {
12 it('should insert single document', () => {
13 let db = Datastore.create();
14 return db.insert(documents[0])
15 .then((inserted) => {
16 expect(inserted).to.be.an('object').that.have.all.keys('_id', 'name');
17 });
18 });
19 });
20
21 describe(`bulk`, () => {
22 it('should insert multiple documents', () => {
23 let db = Datastore.create();
24 return db.insert(documents)
25 .then((inserted) => {
26 expect(inserted).to.be.an('array').that.have.lengthOf(3);
27 });
28 });
29 });
30});
\No newline at end of file