Skip to content

Commit

Permalink
restructure test to match src
Browse files Browse the repository at this point in the history
  • Loading branch information
bartveneman committed Apr 12, 2020
1 parent 03b5aaa commit 877740f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/parse.js
Expand Up @@ -34,7 +34,7 @@ function atrule(atr, { key, declarations }) {
}
}

module.exports = (css, options = {}) => {
module.exports = (css, options) => {
let rules = []
let atrules = []

Expand Down
2 changes: 1 addition & 1 deletion test/declarations.js → 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 {}`))
Expand Down
2 changes: 1 addition & 1 deletion test/rules.js → test/aggregates/rules.js
@@ -1,5 +1,5 @@
const test = require('ava')
const analyze = require('../')
const analyze = require('../../')

const fixture = `
rule1,
Expand Down
2 changes: 1 addition & 1 deletion test/stylesheet.js → 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{}`)
Expand Down
31 changes: 31 additions & 0 deletions 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')
})

0 comments on commit 877740f

Please sign in to comment.