1 | const
|
2 | { expect } = require('chai'),
|
3 | Datastore = require('../src/Datastore')
|
4 |
|
5 | describe('testing document counting', () => {
|
6 | let documents = [
|
7 | { name: 'first document' },
|
8 | { name: 'second document' },
|
9 | { name: 'third document' }
|
10 | ]
|
11 |
|
12 | describe('count', () => {
|
13 | let datastore = Datastore.create(),
|
14 | insert = datastore.insert(documents)
|
15 | it('should get the count of the docs', () => {
|
16 | return insert
|
17 | .then((inserted) => {
|
18 | return datastore.count()
|
19 | }).then((result) => {
|
20 | expect(result).to.be.a('number').that.equals(3)
|
21 | })
|
22 | })
|
23 |
|
24 | it('should get the count of the docs when limiting', () => {
|
25 | return insert
|
26 | .then((inserted) => {
|
27 | return datastore.count().limit(2)
|
28 | }).then((result) => {
|
29 | expect(result).to.be.a('number').that.equals(2)
|
30 | })
|
31 | })
|
32 | })
|
33 | })
|