Skip to content

Commit cfdfff8

Browse files
chore: updated tests
1 parent 3058c99 commit cfdfff8

4 files changed

Lines changed: 24 additions & 13 deletions

File tree

src/test/extension.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ suite("Extension Tests", function () {
1717
});
1818

1919
test("Run Command Reset Cache", async function () {
20-
this.timeout(10000);
2120
const result = await vscode.commands.executeCommand(
2221
"css-scss-modules-intellisense.resetCache"
2322
);

src/test/providers/completionProvider.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ suite("Completion Provider Tests", function () {
1212
"assets/fixtures/fixture-1/Sample.jsx"
1313
);
1414

15+
let doc: vscode.TextDocument;
16+
let editor: vscode.TextEditor;
17+
1518
suiteSetup(async () => {
1619
await vscode.extensions
1720
.getExtension(`${publisher}.${extensionName}`)
1821
?.activate();
22+
23+
doc = await vscode.workspace.openTextDocument(samplePath);
24+
editor = await vscode.window.showTextDocument(doc);
1925
});
2026

2127
suiteTeardown(async () => {
2228
await vscode.commands.executeCommand("workbench.action.closeAllEditors");
2329
});
2430

2531
test("Should provide completion for styles.container", async () => {
26-
const doc = await vscode.workspace.openTextDocument(samplePath);
27-
const editor = await vscode.window.showTextDocument(doc);
28-
2932
// Go to position after "styles"
3033
const lineNum = 3;
3134
const pos = new vscode.Position(
@@ -56,9 +59,6 @@ suite("Completion Provider Tests", function () {
5659
});
5760

5861
test("Should provide all classes for styles", async () => {
59-
const doc = await vscode.workspace.openTextDocument(samplePath);
60-
const editor = await vscode.window.showTextDocument(doc);
61-
6262
// Go to position after "styles"
6363
const lineNum = 3;
6464
const pos = new vscode.Position(

src/test/providers/definitionProvider.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ suite("Definition Provider Tests", function () {
1717
"assets/fixtures/fixture-2/Sample.module.scss"
1818
);
1919

20+
let jsxDoc: vscode.TextDocument;
21+
let scssDoc: vscode.TextDocument;
22+
2023
suiteSetup(async () => {
2124
await vscode.extensions
2225
.getExtension(`${publisher}.${extensionName}`)
2326
?.activate();
27+
28+
jsxDoc = await vscode.workspace.openTextDocument(sampleJsxPath);
29+
scssDoc = await vscode.workspace.openTextDocument(sampleScssPath);
2430
});
2531

2632
suiteTeardown(async () => {
2733
await vscode.commands.executeCommand("workbench.action.closeAllEditors");
2834
});
2935

3036
test("Go-to-Definition jumps to .container in SCSS", async () => {
31-
const doc = await vscode.workspace.openTextDocument(sampleJsxPath);
32-
await vscode.window.showTextDocument(doc);
37+
await vscode.window.showTextDocument(jsxDoc);
38+
const doc = jsxDoc;
3339
const pos = new vscode.Position(3, doc.lineAt(3).text.indexOf("container"));
3440
const locations: vscode.LocationLink[] =
3541
await vscode.commands.executeCommand(
@@ -72,8 +78,8 @@ suite("Definition Provider Tests", function () {
7278
});
7379

7480
test("Go-to-Definition jumps to .container in Script", async () => {
75-
const doc = await vscode.workspace.openTextDocument(sampleScssPath);
76-
await vscode.window.showTextDocument(doc);
81+
await vscode.window.showTextDocument(scssDoc);
82+
const doc = scssDoc;
7783
const pos = new vscode.Position(0, doc.lineAt(0).text.indexOf("container"));
7884
const locations: vscode.LocationLink[] =
7985
await vscode.commands.executeCommand(

src/test/providers/renameProvider.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,24 @@ suite("Rename Provider Tests", function () {
1616
"assets/fixtures/fixture-3/Sample.module.scss"
1717
);
1818

19+
let jsxDoc: vscode.TextDocument;
20+
let scssDoc: vscode.TextDocument;
21+
1922
suiteSetup(async () => {
2023
await vscode.extensions
2124
.getExtension(`${publisher}.${extensionName}`)
2225
?.activate();
26+
27+
jsxDoc = await vscode.workspace.openTextDocument(sampleJsxPath);
28+
scssDoc = await vscode.workspace.openTextDocument(sampleScssPath);
2329
});
2430

2531
suiteTeardown(async () => {
2632
await vscode.commands.executeCommand("workbench.action.closeAllEditors");
2733
});
2834

2935
test("Rename 'container' to 'wrapper' inside CSS Module", async () => {
30-
const doc = await vscode.workspace.openTextDocument(sampleScssPath);
36+
const doc = scssDoc;
3137

3238
const lineNum = 0;
3339
const lineText = doc.lineAt(lineNum).text;
@@ -89,7 +95,7 @@ suite("Rename Provider Tests", function () {
8995
});
9096

9197
test("Rename 'container' to 'wrapper' inside a Script", async () => {
92-
const doc = await vscode.workspace.openTextDocument(sampleJsxPath);
98+
const doc = jsxDoc;
9399

94100
const lineNum = 3;
95101
const lineText = doc.lineAt(lineNum).text;

0 commit comments

Comments
 (0)