Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
netalondon committed Aug 5, 2024
1 parent 647ac42 commit 057697c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
22 changes: 11 additions & 11 deletions components/src/stores/chip.store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("ChipStore", () => {
});

await store.actions.initialize();
await store.actions.loadChip("projects/01/Not/Not.hdl");
await store.actions.loadChip("projects/01/Not.hdl");

expect(store.state.controls.project).toBe("01");
expect(store.state.controls.chipName).toBe("Not");
Expand All @@ -68,12 +68,12 @@ describe("ChipStore", () => {
describe("behavior", () => {
const state = cleanState(async () => {
const store = testChipStore({
"projects/01/Not/Not.hdl": not.hdl,
"projects/01/Not/Not.tst": not.tst,
"projects/01/Not/Not.cmp": not.cmp,
"projects/01/Not.hdl": not.hdl,
"projects/01/Not.tst": not.tst,
"projects/01/Not.cmp": not.cmp,
});
await store.actions.initialize();
await store.actions.loadChip("projects/01/Not/Not.hdl");
await store.actions.loadChip("projects/01/Not.hdl");
return { store };
}, beforeEach);

Expand Down Expand Up @@ -106,7 +106,7 @@ describe("ChipStore", () => {
"projects/01/Not.cmp": not.cmp,
});
await store.actions.initialize();
await store.actions.loadChip("projects/01/Not/Not.hdl");
await store.actions.loadChip("projects/01/Not.hdl");
return { store };
}, beforeEach);

Expand All @@ -124,7 +124,7 @@ describe("ChipStore", () => {
expect(bits(state.store.state.sim.inPins)).toEqual([[0]]);
expect(bits(state.store.state.sim.outPins)).toEqual([[1]]);

await state.store.actions.stepTest(); // Output List
await state.store.actions.stepTest(); // Load, Compare To and Output List

await state.store.actions.stepTest(); // Set in 0
expect(bits(state.store.state.sim.inPins)).toEqual([[0]]);
Expand All @@ -143,7 +143,7 @@ describe("ChipStore", () => {
expect(state.store.state.files.tst).toBe(not.tst);
expect(state.store.state.controls.span).toEqual({
start: 167,
end: 186,
end: 220,
line: 6,
});
});
Expand All @@ -158,9 +158,9 @@ describe("ChipStore", () => {
await state.store.actions.stepTest();

expect(state.store.state.controls.span).toEqual({
start: 235,
end: 236,
line: 14,
start: 269,
end: 270,
line: 16,
});
});
});
Expand Down
7 changes: 6 additions & 1 deletion simulator/src/test/chiptst.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ describe("Chip Test", () => {
},
};

const maybeTest = ChipTest.from({ lines: [repeat] });
const maybeTest = ChipTest.from(
{
lines: [repeat],
},
{ requireLoad: false },
);
expect(maybeTest).toBeOk();
const test = unwrap(maybeTest);
test.outputList([{ id: "time", style: "S", len: 4, lpad: 0, rpad: 0 }]);
Expand Down
4 changes: 2 additions & 2 deletions simulator/src/test/chiptst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ export class ChipTest extends Test<ChipTestInstruction> {
setStatus?: Action<string>;
loadAction?: (path: string) => Promise<Chip>;
compareTo?: Action<string>;
requireLoad?: boolean;
} = {},
): Result<ChipTest, Error> {
const test = new ChipTest(options);

return fill(test, tst);
return fill(test, tst, options.requireLoad);
}

constructor({
Expand All @@ -53,7 +54,6 @@ export class ChipTest extends Test<ChipTestInstruction> {

override async load(filename?: string): Promise<void> {
if (!this.dir) return;
console.log("Loading chip", this.dir, filename);
const chip = await this.doLoad?.(
filename ? `${this.dir}/${filename}` : this.dir,
);
Expand Down

0 comments on commit 057697c

Please sign in to comment.