-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathDotnetUtils.test.ts
More file actions
34 lines (28 loc) · 1.58 KB
/
DotnetUtils.test.ts
File metadata and controls
34 lines (28 loc) · 1.58 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
import DotnetUtils from "../src/DotnetUtils";
describe('DotnetUtils tests', () => {
it('parseCommandArguments should parse dotnet parameters', async () => {
let dotnetParams = '';
let parsedArgs = await DotnetUtils.parseCommandArguments(dotnetParams);
expect(parsedArgs).toEqual({});
dotnetParams = `-o C:\\test\\ --configuration 'Debug' --verbose --test "test value"`;
parsedArgs = await DotnetUtils.parseCommandArguments(dotnetParams);
expect(parsedArgs).toEqual({
'-o': 'C:\\test\\',
'--configuration': `'Debug'`,
'--verbose': undefined,
'--test': `"test value"`
});
});
it ('should find arguments parsed by parseCommandArguments', async () => {
const dotnetParams = `-o C:\\test\\ --configuration 'Debug' --verbose --test "test value"`;
const parsedArgs = await DotnetUtils.parseCommandArguments(dotnetParams);
expect(await DotnetUtils.findArgument(parsedArgs, '')).toEqual(undefined);
expect(await DotnetUtils.findArgument(parsedArgs, '-o')).toEqual('C:\\test\\');
expect(await DotnetUtils.findArgument(parsedArgs, '--output', '-o')).toEqual('C:\\test\\');
expect(await DotnetUtils.findArgument(parsedArgs, '--configuration', '-c')).toEqual(`'Debug'`);
expect(await DotnetUtils.findArgument(parsedArgs, '--verbose')).toEqual(undefined);
expect(await DotnetUtils.findArgument(parsedArgs, '--test')).toEqual(`"test value"`);
// Edge case
expect(await DotnetUtils.findArgument({}, '')).toEqual(undefined);
});
});