-
-
Notifications
You must be signed in to change notification settings - Fork 934
/
standalone-formatter.test.js
48 lines (38 loc) · 1.3 KB
/
standalone-formatter.test.js
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
'use strict';
const configBlockNoEmpty = require('./fixtures/config-block-no-empty');
const standalone = require('../standalone');
const stringFormatter = require('../formatters/stringFormatter');
const stripAnsi = require('strip-ansi');
it('standalone with input css and alternate formatter specified by keyword', async () => {
const { output } = await standalone({
code: 'a {}',
config: configBlockNoEmpty,
formatter: 'string',
});
expect(typeof output).toBe('string');
const strippedOutput = stripAnsi(output);
expect(strippedOutput).toContain('1:3');
expect(strippedOutput).toContain('block-no-empty');
});
it('standalone with input css and alternate formatter function', async () => {
const { output } = await standalone({
code: 'a {}',
config: configBlockNoEmpty,
formatter: stringFormatter,
});
expect(typeof output).toBe('string');
const strippedOutput = stripAnsi(output);
expect(strippedOutput).toContain('1:3');
expect(strippedOutput).toContain('block-no-empty');
});
it('standalone with invalid formatter option', async () => {
await expect(
standalone({
code: 'a {}',
config: configBlockNoEmpty,
formatter: 'invalid',
}),
).rejects.toThrow(
'You must use a valid formatter option: "compact", "github", "json", "string", "tap", "unix", "verbose" or a function',
);
});