Skip to content

Commit dd06a99

Browse files
authored
test(vscode): use stub.resolves over stub.returns with Promise (#862)
1 parent cda9852 commit dd06a99

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

extensions/vscode/src/test/suite/commands/create.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ suite("create command", () => {
4545

4646
suite("file open dialog", () => {
4747
test("is shown when Uri is undefined", async () => {
48-
vscodeStub.window.showOpenDialog.returns(Promise.resolve(undefined));
48+
vscodeStub.window.showOpenDialog.resolves();
4949

5050
await command.create();
5151

@@ -164,7 +164,7 @@ suite("create command", () => {
164164
});
165165

166166
test("runs `dart_frog create` command when project name is valid and uri not defined", async () => {
167-
vscodeStub.window.showOpenDialog.returns(Promise.resolve([targetUri]));
167+
vscodeStub.window.showOpenDialog.resolves([targetUri]);
168168
vscodeStub.window.showInputBox.returns("my_project");
169169

170170
await command.create();

extensions/vscode/src/test/suite/commands/new-middleware.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ suite("new-middleware command", () => {
5353

5454
suite("file open dialog", () => {
5555
test("is shown when Uri is undefined and fails to resolve a path from workspace", async () => {
56-
vscodeStub.window.showOpenDialog.returns(Promise.resolve(undefined));
56+
vscodeStub.window.showOpenDialog.resolves();
5757
utilsStub.resolveDartFrogProjectPathFromWorkspace.returns(undefined);
5858

5959
await command.newMiddleware();
@@ -89,15 +89,15 @@ suite("new-middleware command", () => {
8989
const errorMessage = "Please select a valid directory";
9090

9191
test("is shown when Uri is undefined and selected file is undefined", async () => {
92-
vscodeStub.window.showOpenDialog.returns(Promise.resolve(undefined));
92+
vscodeStub.window.showOpenDialog.resolves();
9393

9494
await command.newMiddleware();
9595

9696
sinon.assert.calledWith(vscodeStub.window.showErrorMessage, errorMessage);
9797
});
9898

9999
test("is not shown when Uri is undefined and selected file is given", async () => {
100-
vscodeStub.window.showOpenDialog.returns(Promise.resolve([invalidUri]));
100+
vscodeStub.window.showOpenDialog.resolves([invalidUri]);
101101

102102
await command.newMiddleware();
103103

@@ -115,7 +115,7 @@ suite("new-middleware command", () => {
115115
"No Dart Frog project found in the selected directory";
116116

117117
test("is shown when Uri is undefined and selected file is invalid", async () => {
118-
vscodeStub.window.showOpenDialog.returns(Promise.resolve([invalidUri]));
118+
vscodeStub.window.showOpenDialog.resolves([invalidUri]);
119119

120120
await command.newMiddleware();
121121

extensions/vscode/src/test/suite/commands/new-route.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ suite("new-route command", () => {
126126
suite("file open dialog", () => {
127127
test("is shown when Uri is undefined and fails to resolve a path from workspace", async () => {
128128
vscodeStub.window.showInputBox.returns(validRouteName);
129-
vscodeStub.window.showOpenDialog.returns(Promise.resolve(undefined));
129+
vscodeStub.window.showOpenDialog.resolves();
130130
utilsStub.resolveDartFrogProjectPathFromWorkspace.returns(undefined);
131131

132132
await command.newRoute();
@@ -164,7 +164,7 @@ suite("new-route command", () => {
164164

165165
test("is shown when Uri is undefined and selected file is undefined", async () => {
166166
vscodeStub.window.showInputBox.returns(validRouteName);
167-
vscodeStub.window.showOpenDialog.returns(Promise.resolve(undefined));
167+
vscodeStub.window.showOpenDialog.resolves();
168168

169169
await command.newRoute();
170170

@@ -173,7 +173,7 @@ suite("new-route command", () => {
173173

174174
test("is not shown when Uri is undefined and selected file is given", async () => {
175175
vscodeStub.window.showInputBox.returns(validRouteName);
176-
vscodeStub.window.showOpenDialog.returns(Promise.resolve([invalidUri]));
176+
vscodeStub.window.showOpenDialog.resolves([invalidUri]);
177177

178178
await command.newRoute();
179179

@@ -192,7 +192,7 @@ suite("new-route command", () => {
192192

193193
test("is shown when Uri is undefined and selected file is invalid", async () => {
194194
vscodeStub.window.showInputBox.returns(validRouteName);
195-
vscodeStub.window.showOpenDialog.returns(Promise.resolve([invalidUri]));
195+
vscodeStub.window.showOpenDialog.resolves([invalidUri]);
196196

197197
await command.newRoute();
198198

0 commit comments

Comments
 (0)