-
Notifications
You must be signed in to change notification settings - Fork 29
/
bulkUpdate.test.js
29 lines (24 loc) · 942 Bytes
/
bulkUpdate.test.js
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
import spinUp from "./spinUp";
let db, schema, queryAndMatchArray, runMutation, close;
beforeEach(async () => {
({ db, schema, queryAndMatchArray, runMutation, close } = await spinUp());
await db.collection("books").insertOne({ title: "Book 1", pages: 100 });
await db.collection("books").insertOne({ title: "Book 2", pages: 150 });
await db.collection("books").insertOne({ title: "Book 3", pages: 200 });
});
afterEach(async () => {
await db.collection("books").deleteMany({});
close();
db = null;
});
test("Bulk update 1", async () => {
await runMutation({
mutation: `updateBooksBulk(Match: {pages_gt: 100}, Updates: {pages: 99}){success}`,
result: "updateBooksBulk"
});
await queryAndMatchArray({
query: "{allBooks(SORT: { title: 1 }){Books{title, pages}}}",
coll: "allBooks",
results: [{ title: "Book 1", pages: 100 }, { title: "Book 2", pages: 99 }, { title: "Book 3", pages: 99 }]
});
});