-
Notifications
You must be signed in to change notification settings - Fork 0
/
skip_take.test.ts
37 lines (34 loc) · 1.32 KB
/
skip_take.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { testSuite, expect } from "manten";
import { nrml, testCollection } from "../../common";
export default testSuite(async ({ describe }) => {
describe("skip", ({ test }) => {
test("works", () => {
const collection = testCollection();
collection.insert({ a: 1, b: 1, c: 1 });
collection.insert({ a: 2, b: 2, c: 2 });
collection.insert({ a: 3, b: 3, c: 3 });
const found = nrml(collection.find({ a: { $gt: 0 } }, { skip: 1 }));
expect(found).toEqual([{ a: 2, b: 2, c: 2 }, { a: 3, b: 3, c: 3 }]);
});
});
describe("take", ({ test }) => {
test("works", () => {
const collection = testCollection();
collection.insert({ a: 1, b: 1, c: 1 });
collection.insert({ a: 2, b: 2, c: 2 });
collection.insert({ a: 3, b: 3, c: 3 });
const found = nrml(collection.find({ a: { $gt: 0 } }, { take: 1 }));
expect(found).toEqual([{ a: 1, b: 1, c: 1 }]);
});
});
describe("skip take", ({ test }) => {
test("works", () => {
const collection = testCollection();
collection.insert({ a: 1, b: 1, c: 1 });
collection.insert({ a: 2, b: 2, c: 2 });
collection.insert({ a: 3, b: 3, c: 3 });
const found = nrml(collection.find({ a: { $gt: 0 } }, { skip: 1, take: 1 }));
expect(found).toEqual([{ a: 2, b: 2, c: 2 }]);
});
});
});