-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathprefixed.test.ts
61 lines (50 loc) · 2.35 KB
/
prefixed.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
import postcss from 'postcss';
import postcssRTLCSS from '../src';
import { PluginOptions } from '../src/@types';
import {
readCSSFile,
runTests,
createSnapshotFileName
} from './utils';
import 'jest-specific-snapshot';
const BASE_NAME = 'prefixed';
runTests({ processUrls: true }, (pluginOptions: PluginOptions): void => {
describe(`[[Mode: ${pluginOptions.mode}]] Prefixed Tests: `, (): void => {
let input = '';
beforeEach(async (): Promise<void> => {
input = input || await readCSSFile('input-prefixed.css');
});
it('Prefixed default', (): void => {
const options: PluginOptions = { ...pluginOptions };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'prefixed-default', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
it('Custom prefixes', (): void => {
const options: PluginOptions = { ...pluginOptions, rtlPrefix: '.rtl', ltrPrefix: '.ltr' };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'custom-prefixes', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
it('Prefixed with array', (): void => {
const options: PluginOptions = { ...pluginOptions, rtlPrefix: ['.rtl', '[dir="rtl"]'], ltrPrefix: ['.ltr', '[dir="ltr"]'] };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'prefixed-with-array', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
it('ignorePrefixedRules false', (): void => {
const options: PluginOptions = { ...pluginOptions, ignorePrefixedRules: false };
const output = postcss([postcssRTLCSS(options)]).process(input);
expect(output.css).toMatchSpecificSnapshot(
createSnapshotFileName(BASE_NAME,'ignore-prefixed-rules-false', pluginOptions.mode)
);
expect(output.warnings()).toHaveLength(0);
});
});
});