forked from AIObjectives/talk-to-the-city-reports
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_pipeline.test.ts
29 lines (27 loc) · 893 Bytes
/
simple_pipeline.test.ts
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
import { describe, it, vi, beforeEach } from 'vitest';
import { expect } from 'vitest';
import CSVNode, { csv_node_data } from '$lib/compute/csv_v0';
import deepCopy from 'deep-copy';
import * as utils from '$lib/utils';
describe('CSVNode class', () => {
beforeEach(() => {
// Reset module mocking before each test
vi.restoreAllMocks();
});
it('should process CSV data correctly from GCS', async () => {
vi.spyOn(utils, 'readFileFromGCS').mockResolvedValue('name,age\nAlice,30\nBob,');
const node = new CSVNode({
id: 'csv',
data: deepCopy(csv_node_data),
position: { x: 0, y: 0 },
type: 'csv_v0'
});
node.data.gcs_path = 'path/to/file.csv';
const result = await node.compute();
expect(result).toEqual([
{ name: 'Alice', age: '30' },
{ name: 'Bob', age: '' }
]);
expect(node.data.dirty).toBe(false);
});
});