Skip to content

Commit

Permalink
Better test for Node#warn
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Jun 18, 2016
1 parent 62a4e92 commit 2d8ef83
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,19 @@ test('error() highlights word in multiline string', t => {
});

test('warn() attaches a warning to the result object', t => {
let warning;
let warner = postcss.plugin('warner', () => {
return (css, result) => {
css.first.warn(result, 'FIRST!');
warning = css.first.warn(result, 'FIRST!');
};
});

let result = postcss([ warner() ]).process('a{}');
t.deepEqual(result.warnings().length, 1);
t.deepEqual(result.warnings()[0].text, 'FIRST!');
t.deepEqual(result.warnings()[0].plugin, 'warner');
return postcss([warner]).process('a{}').then(result => {
t.deepEqual(warning.type, 'warning');
t.deepEqual(warning.text, 'FIRST!');
t.deepEqual(warning.plugin, 'warner');
t.deepEqual(result.warnings(), [warning]);
});
});

test('warn() accepts options', t => {
Expand Down

0 comments on commit 2d8ef83

Please sign in to comment.