Skip to content

Commit d77a3ae

Browse files
committed
feat: Create types in loadTestCaseFixture
1 parent 3ae9773 commit d77a3ae

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

packages/test-case-component/src/loadTestCaseFixture.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
1-
import type { TargetPlainObject, TestCaseFixture, TestCaseSnapshot } from "@cursorless/common";
1+
import type { TestCaseFixture, TestCaseSnapshot } from "@cursorless/common";
22
import { generateHtml } from "./generateHtml";
33
import type { BundledLanguage } from "shiki";
44

5-
async function safeGenerateHtml({
6-
stateName,
7-
state,
8-
languageId,
9-
command,
10-
ide,
11-
thatMarkFinalState
12-
}: {
13-
stateName: string;
14-
state: TestCaseSnapshot;
15-
languageId: BundledLanguage;
16-
command?: any; // Replace `any` with the appropriate type if known
17-
ide?: any; // Replace `any` with the appropriate type if known
18-
thatMarkFinalState?: TargetPlainObject
19-
}) {
20-
console.log("✨" + stateName + "✨");
21-
try {
22-
const genObj = { stateName, state, languageId, command, ide }
23-
return await generateHtml(genObj);
24-
} catch (e) {
25-
console.error("error in state", stateName, e);
26-
console.error(JSON.stringify(state, null, 2));
27-
throw e;
28-
}
29-
}
30-
31-
interface loadFixtureProps extends TestCaseFixture {
5+
interface loadFixtureProps extends DataFixture {
326
filename: string;
337
languageId: BundledLanguage;
348
initialState: TestCaseSnapshot;
359
finalState: TestCaseSnapshot;
3610
}
3711

12+
type StepType = { stepName: "initialState" | "middleState" | "finalState" }
13+
export type DataFixture = TestCaseFixture & StepType
14+
3815
export async function loadTestCaseFixture(data: loadFixtureProps) {
3916
try {
4017
const before = await getBefore({

0 commit comments

Comments
 (0)