-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
nodes.js
30 lines (26 loc) · 876 Bytes
/
nodes.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
30
const { start, getDb, colls } = require(`../index`)
const { createNode, deleteNode } = require(`../nodes`)
const type = `Test`
const node = {
id: `1`,
foo: `bar`,
internal: { type: type },
}
beforeAll(start)
describe(`node`, () => {
it(`should create node ID index`, () => {
createNode(node)
const nodeMetaColl = getDb().getCollection(colls.nodeMeta.name)
expect(nodeMetaColl).toBeDefined()
const nodeMeta = nodeMetaColl.by(`id`, node.id)
const nodeTypeColl = getDb().getCollection(nodeMeta.typeCollName)
expect(nodeTypeColl).toBeDefined()
expect(nodeTypeColl.name).toEqual(`gatsby:nodeType:${type}`)
})
it(`should delete node ID index`, () => {
deleteNode(node)
const nodeMetaColl = getDb().getCollection(colls.nodeMeta.name)
const nodeMeta = nodeMetaColl.by(`id`, node.id)
expect(nodeMeta).toBeUndefined()
})
})