Skip to content

Commit

Permalink
refactor: remove tmp file before run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DIY0R committed Sep 3, 2024
1 parent 2bec8d7 commit a14d1a4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/graph.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import assert from 'node:assert';
import { describe, it } from 'node:test';
import { before, describe, it } from 'node:test';
import { FileGraph, IUuidArray, uuidType } from 'lib';
import { writeFileSync } from 'node:fs';

const graph = FileGraph('data.txt');
const pathGraph = 'data.txt';
const graph = FileGraph(pathGraph);
const data = { name: 'Diy0r', age: new Date().toString() };
let globId = '' as uuidType;

before(() => writeFileSync(pathGraph, ''));

describe('Vertex CRUD Operations', () => {
it('create a vertex and find it by ID', async () => {
const createdVertex = await graph.createVertex(data);
Expand Down Expand Up @@ -43,7 +47,7 @@ describe('Vertex CRUD Operations', () => {

it('update the vertex name', async () => {
const isUpdated = await graph.updateVertex<typeof data>(
vertex => vertex.id === globId && { data: { name: 'Dupo' } },
vertex => vertex.id === globId && { data: { name: 'Dupe' } },
);
assert.strictEqual(isUpdated, true);
});
Expand All @@ -53,7 +57,7 @@ describe('Vertex CRUD Operations', () => {
vertex => vertex.id === globId,
);

assert.strictEqual(foundVertex?.data.name, 'Dupo');
assert.strictEqual(foundVertex?.data.name, 'Dupe');
});

it('create a vertex and delete it', async () => {
Expand Down

0 comments on commit a14d1a4

Please sign in to comment.