diff --git a/src/parse.js b/src/parse.js index ee510f4..d5d87a3 100644 --- a/src/parse.js +++ b/src/parse.js @@ -34,7 +34,7 @@ function atrule(atr, { key, declarations }) { } } -module.exports = (css, options = {}) => { +module.exports = (css, options) => { let rules = [] let atrules = [] diff --git a/test/declarations.js b/test/aggregates/declarations.js similarity index 98% rename from test/declarations.js rename to test/aggregates/declarations.js index 52186da..abd83a8 100644 --- a/test/declarations.js +++ b/test/aggregates/declarations.js @@ -1,5 +1,5 @@ const test = require('ava') -const analyze = require('../') +const analyze = require('../../') test('it does not throw an error when there are no declarations', (t) => { t.notThrows(() => analyze(`a {}`)) diff --git a/test/rules.js b/test/aggregates/rules.js similarity index 98% rename from test/rules.js rename to test/aggregates/rules.js index 0d379f1..7b0ee4e 100644 --- a/test/rules.js +++ b/test/aggregates/rules.js @@ -1,5 +1,5 @@ const test = require('ava') -const analyze = require('../') +const analyze = require('../../') const fixture = ` rule1, diff --git a/test/stylesheet.js b/test/aggregates/stylesheet.js similarity index 96% rename from test/stylesheet.js rename to test/aggregates/stylesheet.js index f4b8687..a2321a6 100644 --- a/test/stylesheet.js +++ b/test/aggregates/stylesheet.js @@ -1,5 +1,5 @@ const test = require('ava') -const analyze = require('../') +const analyze = require('../../') test('uncompressed filesize', (t) => { const actual = analyze(`a{}`) diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..1e4a823 --- /dev/null +++ b/test/index.js @@ -0,0 +1,31 @@ +const test = require('ava') +const analyze = require('../') + +test('does not throw on syntax error', (t) => { + t.notThrows(() => + analyze(` + a { color red } + `) + ) + + t.notThrows(() => + analyze(` + {} + `) + ) +}) + +test('it throws on syntax errors when we ask it to', (t) => { + const error = t.throws( + () => + analyze( + ` + a { color red } + `, + { throwOnSyntaxError: true } + ), + { instanceOf: SyntaxError } + ) + + t.is(error.message, 'Colon is expected') +})