-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: fix error assertions * organize a bit * remove test
- Loading branch information
Showing
2 changed files
with
28 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,70 @@ | ||
const { describe, test } = require('node:test') | ||
const { match } = require('node:assert') | ||
const { rejects } = require('node:assert') | ||
|
||
const postcssrc = require('../src/index.js') | ||
|
||
test('Loading Config - {Error}', () => { | ||
return postcssrc({}, 'test/err').catch(err => { | ||
match(err.message, /^No PostCSS Config found in: (.*)$/) | ||
describe('Loading Config - {Error}', () => { | ||
test('Missing Directory', () => { | ||
return rejects(() => postcssrc({}, 'ghostDir'), { | ||
message: /^No PostCSS Config found in: (.*)$/ | ||
}) | ||
}) | ||
|
||
test('TS - Syntax', () => { | ||
return rejects(() => postcssrc({}, 'test/err/ts'), { | ||
message: /^(Transform failed|ParseError)/ | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Loading Plugins - {Error}', () => { | ||
test('Plugin - {Type} - Invalid', () => { | ||
return postcssrc({}, 'test/err/plugins').catch(err => { | ||
match(err.message, /^Invalid PostCSS Plugin found at: (.*)\n\n\(@.*\)$/) | ||
return rejects(() => postcssrc({}, 'test/err/plugins'), { | ||
message: /^Invalid PostCSS Plugin found at: (.*)\n\n\(@.*\)$/ | ||
}) | ||
}) | ||
|
||
test('Plugin - {Object}', () => { | ||
return postcssrc({}, 'test/err/plugins/object').catch(err => { | ||
match(err.message, /^Loading PostCSS Plugin failed: .*$/m) | ||
return rejects(() => postcssrc({}, 'test/err/plugins/object'), { | ||
message: /^Loading PostCSS Plugin failed: .*$/m | ||
}) | ||
}) | ||
|
||
test('Plugin - {Object} - Options', () => { | ||
return postcssrc({}, 'test/err/plugins/object/options').catch(err => { | ||
match(err.message, /^Loading PostCSS Plugin failed: .*$/m) | ||
return rejects(() => postcssrc({}, 'test/err/plugins/object/options'), { | ||
message: /^Loading PostCSS Plugin failed: .*$/m | ||
}) | ||
}) | ||
|
||
test('Plugin - {Array}', () => { | ||
return postcssrc({}, 'test/err/plugins/array').catch(err => { | ||
match(err.message, /^Cannot find (.*)$/m) | ||
return rejects(() => postcssrc({}, 'test/err/plugins/array'), { | ||
message: /^Cannot find (.*)$/m | ||
}) | ||
}) | ||
|
||
test('Plugin - {Array} - Options', () => { | ||
return postcssrc({}, 'test/err/plugins/array/options').catch(err => { | ||
match(err.message, /^Cannot find (.*)$/m) | ||
return rejects(() => postcssrc({}, 'test/err/plugins/array/options'), { | ||
message: /^Cannot find (.*)$/m | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Loading Options - {Error}', () => { | ||
test('Parser - {String}', () => { | ||
return postcssrc({}, 'test/err/options/parser').catch(err => { | ||
match(err.message, /^Loading PostCSS Parser failed: .*$/m) | ||
return rejects(() => postcssrc({}, 'test/err/options/parser'), { | ||
message: /^Loading PostCSS Parser failed: .*$/m | ||
}) | ||
}) | ||
|
||
test('Syntax - {String}', () => { | ||
return postcssrc({}, 'test/err/options/syntax').catch(err => { | ||
match(err.message, /^Loading PostCSS Syntax failed: .*$/m) | ||
return rejects(() => postcssrc({}, 'test/err/options/syntax'), { | ||
message: /^Loading PostCSS Syntax failed: .*$/m | ||
}) | ||
}) | ||
|
||
test('Stringifier - {String}', () => { | ||
return postcssrc({}, 'test/err/options/stringifier').catch(err => { | ||
match(err.message, /^Loading PostCSS Stringifier failed: .*$/m) | ||
return rejects(() => postcssrc({}, 'test/err/options/stringifier'), { | ||
message: /^Loading PostCSS Stringifier failed: .*$/m | ||
}) | ||
}) | ||
}) | ||
|
||
test('Loading TS Config - {Error} - Syntax', () => { | ||
return postcssrc({}, 'test/err/ts').catch(err => { | ||
match(err.message, /^(Transform failed|ParseError)/) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters