Skip to content

Commit e839863

Browse files
committed
fix test
1 parent db308ea commit e839863

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

tests/ts/test/core/instrument.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ const outputDir = join(tmpdir(), "assemblyscript-unittest-framework");
1010

1111
test("Instrument", async () => {
1212
await compile([fixturePath], outputDir, "--memoryBase 16 --exportTable");
13+
const base = join(outputDir, "constructor");
1314
const wasmPath = join(outputDir, "constructor.wasm");
1415
const sourceCodePath = "tests/ts/fixture/constructor.ts";
15-
const result = await instrument([wasmPath], [sourceCodePath]);
16-
expect(result.length).toEqual(1);
16+
const results = await instrument([wasmPath], [sourceCodePath]);
17+
expect(results.length).toEqual(1);
18+
const result = results[0]!;
1719
const instrumentedWasm = join(outputDir, "constructor.instrumented.wasm");
1820
const debugInfo = join(outputDir, "constructor.debugInfo.json");
1921
const expectInfo = join(outputDir, "constructor.expectInfo.json");
20-
expect(result[0]).toEqual({
21-
sourceWasm: wasmPath,
22-
instrumentedWasm,
23-
debugInfo,
24-
expectInfo,
25-
});
22+
expect(result.baseName).toEqual(base);
23+
expect(result.sourceWasm).toEqual(wasmPath);
24+
expect(result.instrumentedWasm).toEqual(instrumentedWasm);
25+
expect(result.debugInfo).toEqual(debugInfo);
26+
expect(result.expectInfo).toEqual(expectInfo);
2627
expect(fs.existsSync(instrumentedWasm)).toEqual(true);
2728
expect(fs.existsSync(debugInfo)).toEqual(true);
2829
expect(fs.existsSync(expectInfo)).toEqual(true);

tests/ts/test/parser/parser.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { join } from "node:path";
22
// eslint-disable-next-line n/no-extraneous-import
33
import { jest } from "@jest/globals";
44
import { fileURLToPath, URL } from "node:url";
5-
import { SourceFunctionInfo } from "../../../../src/interface.js";
5+
import { InstrumentResult, SourceFunctionInfo } from "../../../../src/interface.js";
66

77
jest.unstable_mockModule("node:fs/promises", () => ({
88
readFile: jest.fn(() => "\n".repeat(50)),
@@ -16,8 +16,7 @@ describe("Parser", () => {
1616
const parser = new Parser();
1717

1818
test("traceParse", async () => {
19-
const debugFilePath = join(dirname, "..", "..", "fixture", "traceParse.debugInfo.json");
20-
await parser.traceParse(debugFilePath);
19+
await parser.traceParse(new InstrumentResult(join(dirname, "..", "..", "fixture", "traceParse")));
2120
expect(parser.functionCovInfoMap).toMatchSnapshot();
2221
expect(parser.functionCovTraceMap).toMatchSnapshot();
2322
});

0 commit comments

Comments
 (0)