Skip to content

Commit b042b38

Browse files
committed
refactor: Move types into single file in test-case-component
1 parent c56ec76 commit b042b38

File tree

4 files changed

+34
-251
lines changed

4 files changed

+34
-251
lines changed

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

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
import { createHighlighter, createCssVariablesTheme } from "shiki";
22
import type { BundledLanguage } from "shiki";
3-
4-
import type {
5-
Command,
6-
CommandLatest,
7-
PlainSpyIDERecordedValues,
8-
TargetPlainObject,
9-
TestCaseFixture,
10-
TestCaseSnapshot
11-
} from "@cursorless/common";
3+
import type { Lang, StepNameType, ExtendedTestCaseSnapshot, DataFixture } from "./types";
4+
import type { Command, CommandLatest, TestCaseFixture } from "@cursorless/common";
125

136
import { createDecorations } from "./helpers";
14-
import type { DataFixture } from "./loadTestCaseFixture";
15-
16-
type Lang = BundledLanguage;
177

188
const myTheme = createCssVariablesTheme({
199
name: "css-variables",
@@ -39,15 +29,6 @@ const highlighter = createHighlighter({
3929
langs: ["javascript", "typescript", "python", "markdown"],
4030
});
4131

42-
type StepNameType = "before" | "during" | "after"
43-
type ExtendedTestCaseSnapshot = TestCaseSnapshot &
44-
Partial<PlainSpyIDERecordedValues> &
45-
{
46-
finalStateMarkHelpers?: {
47-
thatMark?: TargetPlainObject[], sourceMark?: TargetPlainObject[]
48-
}
49-
};
50-
5132
class HTMLGenerator {
5233
private testCaseStates: {
5334
before: ExtendedTestCaseSnapshot | undefined;

packages/test-case-component/src/helpers/typeGuards.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
type LineRange = { type: string; start: number; end: number }
2-
type PositionRange = { type: string; start: { line: number; character: number }; end: { line: number; character: number } };
3-
type RangeType = LineRange | PositionRange;
1+
import type { LineRange, PositionRange, RangeType } from "../types";
42

53
function isLineRange(range: RangeType): range is LineRange {
64
return typeof range.start === "number"
@@ -17,4 +15,3 @@ function isPositionRange(
1715
}
1816

1917
export { isLineRange, isPositionRange }
20-
export type { PositionRange, RangeType }

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
import type { TestCaseFixture, TestCaseSnapshot } from "@cursorless/common";
21
import { generateHtml } from "./generateHtml";
3-
import type { BundledLanguage } from "shiki";
2+
import type { LoadFixtureProps } from "./types";
43

5-
interface loadFixtureProps extends DataFixture {
6-
filename: string;
7-
languageId: BundledLanguage;
8-
initialState: TestCaseSnapshot;
9-
finalState: TestCaseSnapshot;
10-
}
11-
12-
type StepType = { stepName: "initialState" | "middleState" | "finalState" }
13-
export type DataFixture = TestCaseFixture & StepType
14-
15-
export async function loadTestCaseFixture(data: loadFixtureProps) {
4+
export async function loadTestCaseFixture(data: LoadFixtureProps) {
165
const { before, during, after } = await generateHtml(data)
176

187
const { command, filename, languageId: language } = data
Lines changed: 29 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -1,213 +1,29 @@
1-
export type Lang =
2-
| "abap"
3-
| "actionscript-3"
4-
| "ada"
5-
| "apache"
6-
| "apex"
7-
| "apl"
8-
| "applescript"
9-
| "ara"
10-
| "asm"
11-
| "astro"
12-
| "awk"
13-
| "ballerina"
14-
| "bat"
15-
| "batch"
16-
| "beancount"
17-
| "berry"
18-
| "be"
19-
| "bibtex"
20-
| "bicep"
21-
| "blade"
22-
| "c"
23-
| "cadence"
24-
| "cdc"
25-
| "clarity"
26-
| "clojure"
27-
| "clj"
28-
| "cmake"
29-
| "cobol"
30-
| "codeql"
31-
| "ql"
32-
| "coffee"
33-
| "cpp"
34-
| "crystal"
35-
| "csharp"
36-
| "c#"
37-
| "cs"
38-
| "css"
39-
| "cue"
40-
| "cypher"
41-
| "cql"
42-
| "d"
43-
| "dart"
44-
| "dax"
45-
| "diff"
46-
| "docker"
47-
| "dockerfile"
48-
| "dream-maker"
49-
| "elixir"
50-
| "elm"
51-
| "erb"
52-
| "erlang"
53-
| "erl"
54-
| "fish"
55-
| "fsharp"
56-
| "f#"
57-
| "fs"
58-
| "gdresource"
59-
| "gdscript"
60-
| "gdshader"
61-
| "gherkin"
62-
| "git-commit"
63-
| "git-rebase"
64-
| "glimmer-js"
65-
| "gjs"
66-
| "glimmer-ts"
67-
| "gts"
68-
| "glsl"
69-
| "gnuplot"
70-
| "go"
71-
| "graphql"
72-
| "groovy"
73-
| "hack"
74-
| "haml"
75-
| "handlebars"
76-
| "hbs"
77-
| "haskell"
78-
| "hs"
79-
| "hcl"
80-
| "hjson"
81-
| "hlsl"
82-
| "html"
83-
| "http"
84-
| "imba"
85-
| "ini"
86-
| "properties"
87-
| "java"
88-
| "javascript"
89-
| "js"
90-
| "jinja-html"
91-
| "jison"
92-
| "json"
93-
| "json5"
94-
| "jsonc"
95-
| "jsonl"
96-
| "jsonnet"
97-
| "jssm"
98-
| "fsl"
99-
| "jsx"
100-
| "julia"
101-
| "kotlin"
102-
| "kusto"
103-
| "kql"
104-
| "latex"
105-
| "less"
106-
| "liquid"
107-
| "lisp"
108-
| "logo"
109-
| "lua"
110-
| "make"
111-
| "makefile"
112-
| "markdown"
113-
| "md"
114-
| "marko"
115-
| "matlab"
116-
| "mdx"
117-
| "mermaid"
118-
| "narrat"
119-
| "nar"
120-
| "nextflow"
121-
| "nf"
122-
| "nginx"
123-
| "nim"
124-
| "nix"
125-
| "objective-c"
126-
| "objc"
127-
| "objective-cpp"
128-
| "ocaml"
129-
| "pascal"
130-
| "perl"
131-
| "php"
132-
| "plsql"
133-
| "postcss"
134-
| "powerquery"
135-
| "powershell"
136-
| "ps"
137-
| "ps1"
138-
| "prisma"
139-
| "prolog"
140-
| "proto"
141-
| "pug"
142-
| "jade"
143-
| "puppet"
144-
| "purescript"
145-
| "python"
146-
| "py"
147-
| "r"
148-
| "raku"
149-
| "perl6"
150-
| "razor"
151-
| "reg"
152-
| "rel"
153-
| "riscv"
154-
| "rst"
155-
| "ruby"
156-
| "rb"
157-
| "rust"
158-
| "rs"
159-
| "sas"
160-
| "sass"
161-
| "scala"
162-
| "scheme"
163-
| "scss"
164-
| "shaderlab"
165-
| "shader"
166-
| "shellscript"
167-
| "bash"
168-
| "console"
169-
| "sh"
170-
| "shell"
171-
| "zsh"
172-
| "smalltalk"
173-
| "solidity"
174-
| "sparql"
175-
| "sql"
176-
| "ssh-config"
177-
| "stata"
178-
| "stylus"
179-
| "styl"
180-
| "svelte"
181-
| "swift"
182-
| "system-verilog"
183-
| "tasl"
184-
| "tcl"
185-
| "tex"
186-
| "toml"
187-
| "tsx"
188-
| "turtle"
189-
| "twig"
190-
| "typescript"
191-
| "ts"
192-
| "v"
193-
| "vb"
194-
| "cmd"
195-
| "verilog"
196-
| "vhdl"
197-
| "viml"
198-
| "vim"
199-
| "vimscript"
200-
| "vue-html"
201-
| "vue"
202-
| "vyper"
203-
| "vy"
204-
| "wasm"
205-
| "wenyan"
206-
| "文言"
207-
| "wgsl"
208-
| "wolfram"
209-
| "xml"
210-
| "xsl"
211-
| "yaml"
212-
| "yml"
213-
| "zenscript";
1+
import type { TestCaseFixture, TestCaseSnapshot, PlainSpyIDERecordedValues, TargetPlainObject } from "@cursorless/common";
2+
import type { BundledLanguage } from "shiki";
3+
4+
5+
6+
export type StepType = { stepName: "initialState" | "middleState" | "finalState" };
7+
export type DataFixture = TestCaseFixture & StepType;
8+
9+
export interface LoadFixtureProps extends DataFixture {
10+
filename: string;
11+
languageId: BundledLanguage;
12+
initialState: TestCaseSnapshot;
13+
finalState: TestCaseSnapshot;
14+
}
15+
16+
export type Lang = BundledLanguage;
17+
export type StepNameType = "before" | "during" | "after";
18+
19+
export type ExtendedTestCaseSnapshot = TestCaseSnapshot &
20+
Partial<PlainSpyIDERecordedValues> & {
21+
finalStateMarkHelpers?: {
22+
thatMark?: TargetPlainObject[];
23+
sourceMark?: TargetPlainObject[];
24+
};
25+
};
26+
27+
export type LineRange = { type: string; start: number; end: number };
28+
export type PositionRange = { type: string; start: { line: number; character: number }; end: { line: number; character: number } };
29+
export type RangeType = LineRange | PositionRange;

0 commit comments

Comments
 (0)