@lvce-editor/test-worker 13.4.0 → 13.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -86,6 +86,8 @@ export interface SelectItem2Options {
86
86
  readonly label: string;
87
87
  }
88
88
 
89
+ export type TokenRow = readonly string[];
90
+
89
91
  export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
90
92
 
91
93
  interface Workspace {
@@ -238,6 +240,7 @@ interface Editor {
238
240
  readonly shouldHaveDiagnostics: (expectedDiagnostics: readonly Diagnostic[]) => Promise<void>;
239
241
  readonly shouldHaveSelections: (expectedSelections: Uint32Array) => Promise<void>;
240
242
  readonly shouldHaveText: (expectedText: string) => Promise<void>;
243
+ readonly shouldHaveTokens: (expectedTokens: readonly TokenRow[]) => Promise<void>;
241
244
  readonly showHover: () => Promise<void>;
242
245
  readonly sortImports: () => Promise<void>;
243
246
  readonly sourceActionsSelectCurrent: () => Promise<void>;
@@ -2138,6 +2138,33 @@ const shouldHaveText = async expectedText => {
2138
2138
  throw new Error(`Expected editor to have text ${expectedText} but was ${text}`);
2139
2139
  }
2140
2140
  };
2141
+ const areTokensEqual = (actual, expected) => {
2142
+ if (actual.length !== expected.length) {
2143
+ return false;
2144
+ }
2145
+ for (let i = 0; i < actual.length; i++) {
2146
+ const actualRow = actual[i];
2147
+ const expectedRow = expected[i];
2148
+ if (actualRow.length !== expectedRow.length) {
2149
+ return false;
2150
+ }
2151
+ for (let j = 0; j < actualRow.length; j++) {
2152
+ if (actualRow[j] !== expectedRow[j]) {
2153
+ return false;
2154
+ }
2155
+ }
2156
+ }
2157
+ return true;
2158
+ };
2159
+ const shouldHaveTokens = async expectedTokens => {
2160
+ const key = await getEditorKey();
2161
+ const text = await invoke$1('Editor.getTokens', key);
2162
+ if (!areTokensEqual(text, expectedTokens)) {
2163
+ const stringifiedActual = JSON.stringify(text);
2164
+ const stringifiedExpected = JSON.stringify(expectedTokens);
2165
+ throw new Error(`Expected editor to have tokens ${stringifiedExpected} but was ${stringifiedActual}`);
2166
+ }
2167
+ };
2141
2168
  const shouldHaveSelections = async expectedSelections => {
2142
2169
  const key = await getEditorKey();
2143
2170
  const selections = await invoke$1('Editor.getSelections', key);
@@ -2259,6 +2286,7 @@ const Editor = {
2259
2286
  shouldHaveDiagnostics,
2260
2287
  shouldHaveSelections,
2261
2288
  shouldHaveText,
2289
+ shouldHaveTokens,
2262
2290
  showHover,
2263
2291
  sortImports,
2264
2292
  sourceActionsSelectCurrent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "13.4.0",
3
+ "version": "13.5.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",