-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwasm-generate.test.ts
More file actions
33 lines (29 loc) · 1.17 KB
/
wasm-generate.test.ts
File metadata and controls
33 lines (29 loc) · 1.17 KB
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
30
31
32
33
import { beforeAll, describe, expect, it } from 'vitest';
import { wasmGenerate } from '../src/core/generate/rs.ts';
import { testWasmInit } from './utils/wasm.ts';
const TESTS_ASSETS_DIR = './tests/assets';
const SNAPSHOTS_DIR = './snapshots/wasm-generate';
beforeAll(async () => {
await testWasmInit();
});
describe('wasmGenerate', () => {
it.each(['hello_world', 'example'])('should generate a bindgen', async (serviceName) => {
const didFile = `${TESTS_ASSETS_DIR}/${serviceName}.did`;
const result = wasmGenerate({
did_file_path: didFile,
service_name: serviceName,
});
await expect(result.declarations_js).toMatchFileSnapshot(
`${SNAPSHOTS_DIR}/${serviceName}/declarations/${serviceName}.did.js.snapshot`,
);
await expect(result.declarations_ts).toMatchFileSnapshot(
`${SNAPSHOTS_DIR}/${serviceName}/declarations/${serviceName}.did.d.ts.snapshot`,
);
await expect(result.interface_ts).toMatchFileSnapshot(
`${SNAPSHOTS_DIR}/${serviceName}/${serviceName}.d.ts.snapshot`,
);
await expect(result.service_ts).toMatchFileSnapshot(
`${SNAPSHOTS_DIR}/${serviceName}/${serviceName}.ts.snapshot`,
);
});
});