Skip to content

Commit

Permalink
test: check updated vertex
Browse files Browse the repository at this point in the history
  • Loading branch information
DIY0R committed Aug 8, 2024
1 parent 9d21157 commit 0390ca3
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions test/graph.test.ts
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');
});
});

0 comments on commit 0390ca3

Please sign in to comment.