-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathaliases-variables.test.ts
73 lines (60 loc) · 2.78 KB
/
aliases-variables.test.ts
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
import postcss from 'postcss';
import postcssRTLCSS from '../src';
import { PluginOptions } from '../src/@types';
import {
readCSSFile,
runTests,
createSnapshotFileName
} from './utils';
import { aliases } from './constants';
import 'jest-specific-snapshot';
const BASE_NAME = 'aliases-variables';
const baseOptions: PluginOptions = { aliases };
runTests(baseOptions, (pluginOptions: PluginOptions): void => {
describe(`[[Mode: ${pluginOptions.mode}]] Variables Tests:`, (): void => {
let input = '';
beforeEach(async (): Promise<void> => {
input = input || await readCSSFile('input-variables.css');
});
it('aliases default', (): void => {
const options: PluginOptions = { ...pluginOptions, aliases: {} };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'aliases-default', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
it('aliases map', (): void => {
const options: PluginOptions = { ...pluginOptions };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'aliases-map', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
it('wrong aliases', (): void => {
const options: PluginOptions = { ...pluginOptions, aliases: {base: true, parse: false} as unknown as Record<string, string> };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'wrong-aliases', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
it('processEnv = true', (): void => {
const options: PluginOptions = { ...pluginOptions };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'process-env-true', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
it('processEnv = false', (): void => {
const options: PluginOptions = { ...pluginOptions, processEnv: false };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'process-env-false', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
});
});