This repository was archived by the owner on Jun 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathConfigStringResolver.spec.js
More file actions
55 lines (45 loc) · 1.64 KB
/
ConfigStringResolver.spec.js
File metadata and controls
55 lines (45 loc) · 1.64 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
import ConfigStringResolver from '../src/ConfigStringResolver';
import MockConfigContainer from './MockConfigContainer';
describe('ConfigStringResolver', () => {
const container = new MockConfigContainer();
let stringResolver,
environment;
beforeEach(() => {
stringResolver = container.resolve(ConfigStringResolver);
environment = stringResolver.environment;
});
describe('#resolve()', () => {
beforeEach(() => {
environment.setAll({
foo1: 'foo1',
bar1: 'bar1',
foo2: () => 'foo2',
bar2: x => x.valueOf('foo2')
});
});
/**
* @private
* @param {String} before
* @param {String} after
* @returns {String}
*/
const resolve = (before, after) => {
expect(stringResolver.resolve(before)).toEqual(after);
};
it('should resolve `[foo1]` with `foo1`', () => {
resolve('webpack.[foo1].config.js', 'webpack.foo1.config.js');
});
it('should resolve `[bar1]` with `bar1`', () => {
resolve('webpack.[bar1].config.js', 'webpack.bar1.config.js');
});
it('should resolve `[foo2]` with `foo2', () => {
resolve('webpack.[foo2].config.js', 'webpack.foo2.config.js');
});
it('should resolve `[bar2]` with `foo2', () => {
resolve('webpack.[bar2].config.js', 'webpack.foo2.config.js');
});
it('should not resolve `unknown` variables', () => {
resolve('webpack.[name].config.js', 'webpack.[name].config.js');
});
});
});