From 877740fcde22ed66c56b967a1f5020152cd7d66f Mon Sep 17 00:00:00 2001 From: Bart Veneman Date: Sun, 12 Apr 2020 23:13:06 +0200 Subject: [PATCH] restructure test to match src --- src/parse.js | 2 +- test/{ => aggregates}/declarations.js | 2 +- test/{ => aggregates}/rules.js | 2 +- test/{ => aggregates}/stylesheet.js | 2 +- test/index.js | 31 +++++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) rename test/{ => aggregates}/declarations.js (98%) rename test/{ => aggregates}/rules.js (98%) rename test/{ => aggregates}/stylesheet.js (96%) create mode 100644 test/index.js 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') +})