forked from recca0120/vscode-phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.test.ts
More file actions
81 lines (60 loc) · 2.78 KB
/
Copy pathConfiguration.test.ts
File metadata and controls
81 lines (60 loc) · 2.78 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
import { phpUnitProject } from '../../tests/utils';
import { VAR_WORKSPACE_FOLDER } from '../constants';
import { Configuration } from './Configuration';
describe('Configuration Test', () => {
it('key not exists', () => {
const configuration = new Configuration();
expect(configuration.get('foo')).toBeFalsy();
});
it('update key', async () => {
const configuration = new Configuration();
const key = 'foo';
await configuration.update(key, 'bar');
expect(configuration.get(key)).toEqual('bar');
});
it('get key', () => {
// eslint-disable-next-line @typescript-eslint/naming-convention
const configuration = new Configuration({ foo: 'bar', 'foo.bar': 'foobar' });
expect(configuration.get('foo')).toEqual('bar');
expect(configuration.get('foo.bar')).toEqual('foobar');
});
it('get default value when key not exists', () => {
const configuration = new Configuration();
expect(configuration.get('foo', 'bar')).toEqual('bar');
});
it('constructor with map', () => {
const configuration = new Configuration(new Map<string, string>([['foo', 'bar']]));
expect(configuration.get('foo')).toEqual('bar');
expect(configuration.has('buzz')).toBeFalsy();
});
it('constructor with json', () => {
const configuration = new Configuration({ foo: 'bar' });
expect(configuration.get('foo')).toEqual('bar');
expect(configuration.has('buzz')).toBeFalsy();
});
it('get phpunit.xml', async () => {
const configuration = new Configuration({});
const root = phpUnitProject('');
expect(await configuration.getConfigurationFile(root)).toEqual(join(root, 'phpunit.xml'));
});
it('resolves workspace folder placeholder in --configuration for discovery', async () => {
const root = phpUnitProject('');
const configuration = new Configuration({
args: ['--configuration', `${VAR_WORKSPACE_FOLDER}/phpunit.xml`],
});
expect(await configuration.getConfigurationFile(root)).toEqual(join(root, 'phpunit.xml'));
});
it('can not get phpunit.xml', async () => {
const configuration = new Configuration({ args: ['-c', 'src/phpunit.xml'] });
expect(await configuration.getConfigurationFile()).toBeUndefined();
});
it('get phpunit.xml with ${workspaceFolder} in --configuration arg', async () => {
const root = phpUnitProject('');
const configuration = new Configuration({
args: [`--configuration=\${workspaceFolder}/phpunit.xml`],
});
expect(await configuration.getConfigurationFile(root)).toEqual(join(root, 'phpunit.xml'));
});
});