Skip to content

Commit a6ca84e

Browse files
committed
Lint tests files
1 parent f2e3c96 commit a6ca84e

14 files changed

+573
-573
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
],
4848
"scripts": {
4949
"test": "jest --clearCache && jest --verbose",
50-
"lint": "eslint src/**/*.ts",
50+
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
5151
"clean": "./scripts/clean.sh",
5252
"copy": "./scripts/copy.sh",
5353
"modify-dts": "replace-in-file --configFile=config.replace.js",

tests/aliases-custom-declarations.test.ts

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import postcss from 'postcss';
22
import postcssRTLCSS from '../src';
33
import { PluginOptions } from '../src/@types';
44
import {
5-
readCSSFile,
6-
runTests,
7-
createSnapshotFileName
5+
readCSSFile,
6+
runTests,
7+
createSnapshotFileName
88
} from './utils';
99
import { propsAliases } from './constants';
1010
import 'jest-specific-snapshot';
@@ -17,50 +17,50 @@ const baseOptions: PluginOptions = {
1717

1818
runTests(baseOptions, (pluginOptions: PluginOptions): void => {
1919

20-
describe(`[[Mode: ${pluginOptions.mode}]] Aliases Tests:`, (): void => {
21-
22-
let input = '';
20+
describe(`[[Mode: ${pluginOptions.mode}]] Aliases Tests:`, (): void => {
21+
22+
let input = '';
2323

24-
beforeEach(async (): Promise<void> => {
25-
input = input || await readCSSFile('input-aliases.css');
26-
});
24+
beforeEach(async (): Promise<void> => {
25+
input = input || await readCSSFile('input-aliases.css');
26+
});
2727

28-
it('without aliases and safeBothPrefix false', (): void => {
29-
const options: PluginOptions = { ...pluginOptions, aliases: {} };
30-
const output = postcss([postcssRTLCSS(options)]).process(input);
31-
expect(output.css).toMatchSpecificSnapshot(
32-
createSnapshotFileName(BASE_NAME,'no-aliases-safe-both-prefix-false', pluginOptions.mode)
33-
);
34-
expect(output.warnings()).toHaveLength(0);
35-
});
28+
it('without aliases and safeBothPrefix false', (): void => {
29+
const options: PluginOptions = { ...pluginOptions, aliases: {} };
30+
const output = postcss([postcssRTLCSS(options)]).process(input);
31+
expect(output.css).toMatchSpecificSnapshot(
32+
createSnapshotFileName(BASE_NAME,'no-aliases-safe-both-prefix-false', pluginOptions.mode)
33+
);
34+
expect(output.warnings()).toHaveLength(0);
35+
});
3636

37-
it('without aliases and safeBothPrefix true', (): void => {
38-
const options: PluginOptions = { ...pluginOptions, aliases: {}, safeBothPrefix: true };
39-
const output = postcss([postcssRTLCSS(options)]).process(input);
40-
expect(output.css).toMatchSpecificSnapshot(
41-
createSnapshotFileName(BASE_NAME,'no-aliases-safe-both-prefix-true', pluginOptions.mode)
42-
);
43-
expect(output.warnings()).toHaveLength(0);
44-
});
37+
it('without aliases and safeBothPrefix true', (): void => {
38+
const options: PluginOptions = { ...pluginOptions, aliases: {}, safeBothPrefix: true };
39+
const output = postcss([postcssRTLCSS(options)]).process(input);
40+
expect(output.css).toMatchSpecificSnapshot(
41+
createSnapshotFileName(BASE_NAME,'no-aliases-safe-both-prefix-true', pluginOptions.mode)
42+
);
43+
expect(output.warnings()).toHaveLength(0);
44+
});
4545

46-
it('with aliases and safeBothPrefix false', (): void => {
47-
const options: PluginOptions = { ...pluginOptions };
48-
const output = postcss([postcssRTLCSS(options)]).process(input);
49-
expect(output.css).toMatchSpecificSnapshot(
50-
createSnapshotFileName(BASE_NAME,'with-aliases-safe-both-prefix-false', pluginOptions.mode)
51-
);
52-
expect(output.warnings()).toHaveLength(0);
53-
});
46+
it('with aliases and safeBothPrefix false', (): void => {
47+
const options: PluginOptions = { ...pluginOptions };
48+
const output = postcss([postcssRTLCSS(options)]).process(input);
49+
expect(output.css).toMatchSpecificSnapshot(
50+
createSnapshotFileName(BASE_NAME,'with-aliases-safe-both-prefix-false', pluginOptions.mode)
51+
);
52+
expect(output.warnings()).toHaveLength(0);
53+
});
5454

55-
it('with aliases and safeBothPrefix true', (): void => {
56-
const options: PluginOptions = { ...pluginOptions, safeBothPrefix: true };
57-
const output = postcss([postcssRTLCSS(options)]).process(input);
58-
expect(output.css).toMatchSpecificSnapshot(
59-
createSnapshotFileName(BASE_NAME,'with-aliases-safe-both-prefix-true', pluginOptions.mode)
60-
);
61-
expect(output.warnings()).toHaveLength(0);
62-
});
55+
it('with aliases and safeBothPrefix true', (): void => {
56+
const options: PluginOptions = { ...pluginOptions, safeBothPrefix: true };
57+
const output = postcss([postcssRTLCSS(options)]).process(input);
58+
expect(output.css).toMatchSpecificSnapshot(
59+
createSnapshotFileName(BASE_NAME,'with-aliases-safe-both-prefix-true', pluginOptions.mode)
60+
);
61+
expect(output.warnings()).toHaveLength(0);
62+
});
6363

64-
});
64+
});
6565

6666
});

tests/aliases-variables.test.ts

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import postcss from 'postcss';
22
import postcssRTLCSS from '../src';
33
import { PluginOptions } from '../src/@types';
44
import {
5-
readCSSFile,
6-
runTests,
7-
createSnapshotFileName
5+
readCSSFile,
6+
runTests,
7+
createSnapshotFileName
88
} from './utils';
99
import { aliases } from './constants';
1010
import 'jest-specific-snapshot';
@@ -15,59 +15,59 @@ const baseOptions: PluginOptions = { aliases };
1515

1616
runTests(baseOptions, (pluginOptions: PluginOptions): void => {
1717

18-
describe(`[[Mode: ${pluginOptions.mode}]] Variables Tests:`, (): void => {
18+
describe(`[[Mode: ${pluginOptions.mode}]] Variables Tests:`, (): void => {
1919

20-
let input = '';
21-
22-
beforeEach(async (): Promise<void> => {
23-
input = input || await readCSSFile('input-variables.css');
24-
});
25-
26-
it('aliases default', (): void => {
27-
const options: PluginOptions = { ...pluginOptions, aliases: {} };
28-
const output = postcss([postcssRTLCSS(options)]).process(input);
29-
expect(output.css).toMatchSpecificSnapshot(
30-
createSnapshotFileName(BASE_NAME,'aliases-default', pluginOptions.mode)
31-
);
32-
expect(output.warnings()).toHaveLength(0);
33-
});
34-
35-
it('aliases map', (): void => {
36-
const options: PluginOptions = { ...pluginOptions };
37-
const output = postcss([postcssRTLCSS(options)]).process(input);
38-
expect(output.css).toMatchSpecificSnapshot(
39-
createSnapshotFileName(BASE_NAME,'aliases-map', pluginOptions.mode)
40-
);
41-
expect(output.warnings()).toHaveLength(0);
42-
});
43-
44-
it('wrong aliases', (): void => {
45-
const options: PluginOptions = { ...pluginOptions, aliases: {base: true, parse: false} as unknown as Record<string, string> };
46-
const output = postcss([postcssRTLCSS(options)]).process(input);
47-
expect(output.css).toMatchSpecificSnapshot(
48-
createSnapshotFileName(BASE_NAME,'wrong-aliases', pluginOptions.mode)
49-
);
50-
expect(output.warnings()).toHaveLength(0);
51-
});
20+
let input = '';
5221

53-
it('processEnv = true', (): void => {
54-
const options: PluginOptions = { ...pluginOptions };
55-
const output = postcss([postcssRTLCSS(options)]).process(input);
56-
expect(output.css).toMatchSpecificSnapshot(
57-
createSnapshotFileName(BASE_NAME,'process-env-true', pluginOptions.mode)
58-
);
59-
expect(output.warnings()).toHaveLength(0);
60-
});
22+
beforeEach(async (): Promise<void> => {
23+
input = input || await readCSSFile('input-variables.css');
24+
});
25+
26+
it('aliases default', (): void => {
27+
const options: PluginOptions = { ...pluginOptions, aliases: {} };
28+
const output = postcss([postcssRTLCSS(options)]).process(input);
29+
expect(output.css).toMatchSpecificSnapshot(
30+
createSnapshotFileName(BASE_NAME,'aliases-default', pluginOptions.mode)
31+
);
32+
expect(output.warnings()).toHaveLength(0);
33+
});
34+
35+
it('aliases map', (): void => {
36+
const options: PluginOptions = { ...pluginOptions };
37+
const output = postcss([postcssRTLCSS(options)]).process(input);
38+
expect(output.css).toMatchSpecificSnapshot(
39+
createSnapshotFileName(BASE_NAME,'aliases-map', pluginOptions.mode)
40+
);
41+
expect(output.warnings()).toHaveLength(0);
42+
});
43+
44+
it('wrong aliases', (): void => {
45+
const options: PluginOptions = { ...pluginOptions, aliases: {base: true, parse: false} as unknown as Record<string, string> };
46+
const output = postcss([postcssRTLCSS(options)]).process(input);
47+
expect(output.css).toMatchSpecificSnapshot(
48+
createSnapshotFileName(BASE_NAME,'wrong-aliases', pluginOptions.mode)
49+
);
50+
expect(output.warnings()).toHaveLength(0);
51+
});
52+
53+
it('processEnv = true', (): void => {
54+
const options: PluginOptions = { ...pluginOptions };
55+
const output = postcss([postcssRTLCSS(options)]).process(input);
56+
expect(output.css).toMatchSpecificSnapshot(
57+
createSnapshotFileName(BASE_NAME,'process-env-true', pluginOptions.mode)
58+
);
59+
expect(output.warnings()).toHaveLength(0);
60+
});
61+
62+
it('processEnv = false', (): void => {
63+
const options: PluginOptions = { ...pluginOptions, processEnv: false };
64+
const output = postcss([postcssRTLCSS(options)]).process(input);
65+
expect(output.css).toMatchSpecificSnapshot(
66+
createSnapshotFileName(BASE_NAME,'process-env-false', pluginOptions.mode)
67+
);
68+
expect(output.warnings()).toHaveLength(0);
69+
});
6170

62-
it('processEnv = false', (): void => {
63-
const options: PluginOptions = { ...pluginOptions, processEnv: false };
64-
const output = postcss([postcssRTLCSS(options)]).process(input);
65-
expect(output.css).toMatchSpecificSnapshot(
66-
createSnapshotFileName(BASE_NAME,'process-env-false', pluginOptions.mode)
67-
);
68-
expect(output.warnings()).toHaveLength(0);
6971
});
70-
71-
});
7272

7373
});

tests/basic-options.test.ts

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,78 @@ import postcss from 'postcss';
22
import postcssRTLCSS from '../src';
33
import { PluginOptions, Source } from '../src/@types';
44
import {
5-
readCSSFile,
6-
runTests,
7-
createSnapshotFileName
5+
readCSSFile,
6+
runTests,
7+
createSnapshotFileName
88
} from './utils';
99
import 'jest-specific-snapshot';
1010

1111
const BASE_NAME = 'basic-options';
1212

1313
runTests({}, (pluginOptions: PluginOptions): void => {
1414

15-
describe(`[[Mode: ${pluginOptions.mode}]] Basic Options Tests: `, (): void => {
15+
describe(`[[Mode: ${pluginOptions.mode}]] Basic Options Tests: `, (): void => {
16+
17+
let input = '';
18+
19+
beforeEach(async (): Promise<void> => {
20+
input = input || await readCSSFile('input.css');
21+
});
22+
23+
it('Basic', (): void => {
24+
const options: PluginOptions = { ...pluginOptions };
25+
const output = postcss([postcssRTLCSS(options)]).process(input);
26+
expect(output.css).toMatchSpecificSnapshot(
27+
createSnapshotFileName(BASE_NAME,'basic', pluginOptions.mode)
28+
);
29+
expect(output.warnings()).toHaveLength(0);
30+
});
31+
32+
it('{source: rtl}', (): void => {
33+
const options: PluginOptions = { ...pluginOptions, source: Source.rtl };
34+
const output = postcss([postcssRTLCSS(options)]).process(input);
35+
expect(output.css).toMatchSpecificSnapshot(
36+
createSnapshotFileName(BASE_NAME,'source-rtl', pluginOptions.mode)
37+
);
38+
expect(output.warnings()).toHaveLength(0);
39+
});
40+
41+
it('{processUrls: true}', (): void => {
42+
const options: PluginOptions = { ...pluginOptions, processUrls: true };
43+
const output = postcss([postcssRTLCSS(options)]).process(input);
44+
expect(output.css).toMatchSpecificSnapshot(
45+
createSnapshotFileName(BASE_NAME,'process-url-true', pluginOptions.mode)
46+
);
47+
expect(output.warnings()).toHaveLength(0);
48+
});
49+
50+
it('{processKeyFrames: true}', (): void => {
51+
const options: PluginOptions = { ...pluginOptions, processKeyFrames: true };
52+
const output = postcss([postcssRTLCSS(options)]).process(input);
53+
expect(output.css).toMatchSpecificSnapshot(
54+
createSnapshotFileName(BASE_NAME,'process-keyframes-true', pluginOptions.mode)
55+
);
56+
expect(output.warnings()).toHaveLength(0);
57+
});
58+
59+
it('{source: rtl, processKeyFrames: true}', (): void => {
60+
const options: PluginOptions = { ...pluginOptions, source: Source.rtl, processKeyFrames: true };
61+
const output = postcss([postcssRTLCSS(options)]).process(input);
62+
expect(output.css).toMatchSpecificSnapshot(
63+
createSnapshotFileName(BASE_NAME,'source-rtl-and-process-keyframes-true', pluginOptions.mode)
64+
);
65+
expect(output.warnings()).toHaveLength(0);
66+
});
67+
68+
it('{useCalc: true}', (): void => {
69+
const options: PluginOptions = { ...pluginOptions, useCalc: true };
70+
const output = postcss([postcssRTLCSS(options)]).process(input);
71+
expect(output.css).toMatchSpecificSnapshot(
72+
createSnapshotFileName(BASE_NAME,'use-calc-true', pluginOptions.mode)
73+
);
74+
expect(output.warnings()).toHaveLength(0);
75+
});
1676

17-
let input = '';
18-
19-
beforeEach(async (): Promise<void> => {
20-
input = input || await readCSSFile('input.css');
21-
});
22-
23-
it('Basic', (): void => {
24-
const options: PluginOptions = { ...pluginOptions };
25-
const output = postcss([postcssRTLCSS(options)]).process(input);
26-
expect(output.css).toMatchSpecificSnapshot(
27-
createSnapshotFileName(BASE_NAME,'basic', pluginOptions.mode)
28-
);
29-
expect(output.warnings()).toHaveLength(0);
30-
});
31-
32-
it('{source: rtl}', (): void => {
33-
const options: PluginOptions = { ...pluginOptions, source: Source.rtl };
34-
const output = postcss([postcssRTLCSS(options)]).process(input);
35-
expect(output.css).toMatchSpecificSnapshot(
36-
createSnapshotFileName(BASE_NAME,'source-rtl', pluginOptions.mode)
37-
);
38-
expect(output.warnings()).toHaveLength(0);
39-
});
40-
41-
it('{processUrls: true}', (): void => {
42-
const options: PluginOptions = { ...pluginOptions, processUrls: true };
43-
const output = postcss([postcssRTLCSS(options)]).process(input);
44-
expect(output.css).toMatchSpecificSnapshot(
45-
createSnapshotFileName(BASE_NAME,'process-url-true', pluginOptions.mode)
46-
);
47-
expect(output.warnings()).toHaveLength(0);
48-
});
49-
50-
it('{processKeyFrames: true}', (): void => {
51-
const options: PluginOptions = { ...pluginOptions, processKeyFrames: true };
52-
const output = postcss([postcssRTLCSS(options)]).process(input);
53-
expect(output.css).toMatchSpecificSnapshot(
54-
createSnapshotFileName(BASE_NAME,'process-keyframes-true', pluginOptions.mode)
55-
);
56-
expect(output.warnings()).toHaveLength(0);
57-
});
58-
59-
it('{source: rtl, processKeyFrames: true}', (): void => {
60-
const options: PluginOptions = { ...pluginOptions, source: Source.rtl, processKeyFrames: true };
61-
const output = postcss([postcssRTLCSS(options)]).process(input);
62-
expect(output.css).toMatchSpecificSnapshot(
63-
createSnapshotFileName(BASE_NAME,'source-rtl-and-process-keyframes-true', pluginOptions.mode)
64-
);
65-
expect(output.warnings()).toHaveLength(0);
66-
});
67-
68-
it('{useCalc: true}', (): void => {
69-
const options: PluginOptions = { ...pluginOptions, useCalc: true };
70-
const output = postcss([postcssRTLCSS(options)]).process(input);
71-
expect(output.css).toMatchSpecificSnapshot(
72-
createSnapshotFileName(BASE_NAME,'use-calc-true', pluginOptions.mode)
73-
);
74-
expect(output.warnings()).toHaveLength(0);
7577
});
76-
77-
});
7878

7979
});

0 commit comments

Comments
 (0)