Skip to content
Snippets Groups Projects
Commit cf27478a authored by Marcos Pieras's avatar Marcos Pieras
Browse files

test: adds populate template test

parent bb93fe15
No related branches found
No related tags found
2 merge requests!42test: adds return message to handle e2e tests,!40test: adds test on populate template
Pipeline #146820 passed
import { expect, test, describe, it } from 'bun:test';
import { populateTemplate } from './../../utils/insights';
import { type GraphQueryResultMetaFromBackend } from 'ts-common';
const mockResult: GraphQueryResultMetaFromBackend = {
metaData: {
topological: {
density: 0,
self_loops: 0,
},
nodes: {
count: 1,
labels: ['NodeTypeA'],
types: {
NodeTypeA: {
count: 1,
attributes: {
age: {
attributeType: 'number',
statistics: {
min: 10,
max: 50,
average: 42,
count: 100,
},
},
},
},
},
},
edges: {
count: 0,
labels: [],
types: {},
},
},
nodeCounts: { updatedAt: 2313 },
nodes: [],
edges: [],
};
describe('populateTemplate', () => {
it('should replace statistic variables correctly', async () => {
const template = 'The mean value is {{ statistic:NodeTypeA • age • average }}.';
const expectedOutput = 'The mean value is 42 .';
const result = await populateTemplate(template, mockResult, []);
expect(result).toBe(expectedOutput);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment