Skip to content

Commit 81646b4

Browse files
Assert that the domain contains the content range (#3163)
1 parent ec45df0 commit 81646b4

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
ScopeSupportFacet,
33
ScopeType,
44
PlaintextScopeSupportFacet,
5+
ScopeRangeConfig,
56
} from "@cursorless/common";
67
import {
78
asyncSafety,
@@ -132,9 +133,10 @@ async function runTest(file: string, languageId: string, facetId: string) {
132133
await openNewEditor(code, { languageId });
133134

134135
const editor = ide.activeTextEditor!;
136+
const updateFixture = shouldUpdateFixtures();
135137

136138
const [outputFixture, numScopes] = ((): [string, number] => {
137-
const config = {
139+
const config: ScopeRangeConfig = {
138140
visibleOnly: false,
139141
scopeType,
140142
};
@@ -147,6 +149,16 @@ async function runTest(file: string, languageId: string, facetId: string) {
147149
includeNestedTargets: false,
148150
},
149151
);
152+
153+
if (!updateFixture) {
154+
assert.isFalse(
155+
iterationScopes.some((s) =>
156+
s.ranges.some((r) => !s.domain.contains(r.range)),
157+
),
158+
"Iteration range should not contain the domain",
159+
);
160+
}
161+
150162
return [
151163
serializeIterationScopeFixture(code, iterationScopes),
152164
iterationScopes.length,
@@ -155,10 +167,25 @@ async function runTest(file: string, languageId: string, facetId: string) {
155167

156168
const scopes = scopeProvider.provideScopeRanges(editor, config);
157169

170+
if (!updateFixture) {
171+
assert.isFalse(
172+
scopes.some((s) =>
173+
s.targets.some((t) => !s.domain.contains(t.contentRange)),
174+
),
175+
"Content range should not contain the domain",
176+
);
177+
assert.isFalse(
178+
scopes.some((s) =>
179+
s.targets.some((t) => !s.domain.contains(t.contentRange)),
180+
),
181+
"Content range should not contain the removal range",
182+
);
183+
}
184+
158185
return [serializeScopeFixture(facetId, code, scopes), scopes.length];
159186
})();
160187

161-
if (shouldUpdateFixtures()) {
188+
if (updateFixture) {
162189
await fsp.writeFile(file, outputFixture);
163190
} else {
164191
assert.isAbove(numScopes, 0, "No scopes found");

0 commit comments

Comments
 (0)