|
1 | | -var postcss = require('postcss'); |
2 | | - |
3 | | -var plugin = require('./'); |
4 | | - |
5 | | -var test = function (input, output, opts) { |
6 | | - return postcss([ plugin(opts) ]).process(input) |
7 | | - .then(function (result) { |
8 | | - expect(result.css).toEqual(output); |
9 | | - expect(result.warnings().length).toBe(0); |
10 | | - }); |
11 | | -}; |
12 | | - |
13 | | -describe('postcss-disabled', function () { |
14 | | - |
15 | | - it('default behavior, no options', function () { |
16 | | - return test( |
17 | | - '.foo:disabled { background-color: #f9f9f9; }', |
18 | | - '.foo:disabled, .foo[disabled] { background-color: #f9f9f9; }', |
19 | | - {} |
20 | | - ); |
21 | | - }); |
22 | | - |
23 | | - it('addAttributes: true', function () { |
24 | | - return test( |
25 | | - '.foo:disabled { background-color: #f9f9f9; }', |
26 | | - '.foo:disabled, .foo[disabled] { background-color: #f9f9f9; }', |
27 | | - { addAttribute: true } |
28 | | - ); |
29 | | - }); |
| 1 | +const postcss = require('postcss'); |
| 2 | +const { equal } = require('node:assert'); |
| 3 | +const { test } = require('node:test'); |
| 4 | + |
| 5 | +const plugin = require('./'); |
| 6 | + |
| 7 | +async function run(input, output, opts = {}) { |
| 8 | + let result = await postcss([plugin(opts)]).process(input, { |
| 9 | + from: undefined, |
| 10 | + }); |
| 11 | + equal(result.css, output); |
| 12 | + equal(result.warnings().length, 0); |
| 13 | +} |
| 14 | + |
| 15 | +test('default behavior, no options', async () => { |
| 16 | + await run( |
| 17 | + '.foo:disabled { background-color: #f9f9f9; }', |
| 18 | + '.foo:disabled, .foo[disabled] { background-color: #f9f9f9; }', |
| 19 | + {} |
| 20 | + ); |
| 21 | +}); |
30 | 22 |
|
31 | | - it('addAttributes: false', function () { |
32 | | - return test( |
33 | | - '.foo:disabled { background-color: #f9f9f9; }', |
34 | | - '.foo:disabled { background-color: #f9f9f9; }', |
35 | | - { addAttribute: false } |
36 | | - ); |
37 | | - }); |
| 23 | +test('addAttributes: true', async () => { |
| 24 | + await run( |
| 25 | + '.foo:disabled { background-color: #f9f9f9; }', |
| 26 | + '.foo:disabled, .foo[disabled] { background-color: #f9f9f9; }', |
| 27 | + { addAttribute: true } |
| 28 | + ); |
| 29 | +}); |
38 | 30 |
|
39 | | - it('addClass: true', function () { |
40 | | - return test( |
41 | | - '.foo:disabled { background-color: #f9f9f9; }', |
42 | | - '.foo:disabled, .foo.disabled, .foo[disabled] { background-color: #f9f9f9; }', |
43 | | - { addClass: true } |
44 | | - ); |
45 | | - }); |
| 31 | +test('addAttributes: false', async () => { |
| 32 | + await run( |
| 33 | + '.foo:disabled { background-color: #f9f9f9; }', |
| 34 | + '.foo:disabled { background-color: #f9f9f9; }', |
| 35 | + { addAttribute: false } |
| 36 | + ); |
| 37 | +}); |
46 | 38 |
|
47 | | - it('addClass: false', function () { |
48 | | - return test( |
49 | | - '.foo:disabled { background-color: #f9f9f9; }', |
50 | | - '.foo:disabled, .foo[disabled] { background-color: #f9f9f9; }', |
51 | | - { addClass: false } |
52 | | - ); |
53 | | - }); |
| 39 | +test('addClass: true', async () => { |
| 40 | + await run( |
| 41 | + '.foo:disabled { background-color: #f9f9f9; }', |
| 42 | + '.foo:disabled, .foo.disabled, .foo[disabled] { background-color: #f9f9f9; }', |
| 43 | + { addClass: true } |
| 44 | + ); |
| 45 | +}); |
54 | 46 |
|
| 47 | +test('addClass: false', async () => { |
| 48 | + await run( |
| 49 | + '.foo:disabled { background-color: #f9f9f9; }', |
| 50 | + '.foo:disabled, .foo[disabled] { background-color: #f9f9f9; }', |
| 51 | + { addClass: false } |
| 52 | + ); |
55 | 53 | }); |
0 commit comments