-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathswaCliTaskProvider.test.ts
More file actions
58 lines (48 loc) · 2.21 KB
/
swaCliTaskProvider.test.ts
File metadata and controls
58 lines (48 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { ShellExecution, Task, workspace } from 'vscode';
import { SwaTaskProvider } from '../extension.bundle';
import { getWorkspaceUri } from './testUtils';
interface ITestCase {
workspaceName: string;
hasDabConfig?: boolean;
}
const testCases: ITestCase[] = [
{
workspaceName: 'react-basic-dab',
hasDabConfig: true,
},
{
workspaceName: 'react-basic',
hasDabConfig: false,
},
];
function verifyTaskForkWorkspace(testCase: ITestCase, task: Task) {
const execution = task.execution as ShellExecution;
if (testCase.hasDabConfig) {
const message = `Expected --data-api-location argument to${testCase.hasDabConfig ? '' : ' NOT'} be present in task shell execution. Found args: ${execution.args?.join(' ')}`;
assert.strictEqual(execution.args?.includes('--data-api-location'), testCase.hasDabConfig, message);
}
}
suite('SWA task provider', async () => {
const taskProvider = new SwaTaskProvider();
for (const testCase of testCases) {
test(testCase.workspaceName, async () => {
const workspaceUri = getWorkspaceUri(testCase.workspaceName);
const workspaceFolder = workspace.getWorkspaceFolder(workspaceUri);
if (workspaceFolder) {
const tasks = await taskProvider.provideTasksForWorkspaceFolder(workspaceFolder);
tasks.forEach((task) => {
verifyTaskForkWorkspace(testCase, task);
});
}
});
}
});