-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
import { FileGraph } from 'lib'; | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
import { FileGraph } from 'lib'; | ||
|
||
import test from 'node:test'; | ||
const graph = FileGraph('./data.txt'); | ||
test('create Vertex and findOne', async t => { | ||
const model = { name: 'Dyor', age: new Date().toString() }; | ||
const id = await graph.createVertex(model); | ||
const finModel = await graph.findOne<typeof model>(model => model.id == id); | ||
console.log(finModel); | ||
assert.deepStrictEqual({ id, ...model }, finModel); | ||
const myVertex = { name: 'Diy0r', age: new Date().toString() }; | ||
let globId = '6c5febc1-161b-46c7-abf6-b20088fd410e'; | ||
describe('CRUD', t => { | ||
it('create Vertex and findOne', async t => { | ||
const createdVertexId = await graph.createVertex(myVertex); | ||
const findVertex = await graph.findOne<typeof myVertex>( | ||
vertex => vertex.id == createdVertexId, | ||
); | ||
assert.deepStrictEqual({ id: createdVertexId, ...myVertex }, findVertex); | ||
globId = findVertex.id; | ||
}); | ||
it('update Vertex', async t => { | ||
const isUpdate = await graph.updateVertex<typeof myVertex>(model => | ||
model.id == globId ? { name: 'Dupo', id: '121212', sdsds: 'sdsd' } : null, | ||
); | ||
assert.equal(isUpdate, true); | ||
}); | ||
|
||
it('check updated vertex name', async t => { | ||
const findVertex = await graph.findOne<typeof myVertex>( | ||
vertex => vertex.id == globId, | ||
); | ||
assert.deepStrictEqual(findVertex.name, 'Dupo'); | ||
}); | ||
}); |