Skip to content

Commit

Permalink
add tests for unist-util-select compat, property names
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnbot committed May 15, 2018
1 parent 375bb92 commit 8002a8b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fse = require('fs-extra')
const path = require('path')
const remove = require('unist-util-remove')
const select = require('unist-util-select')
const test = require('ava')
const {parse, parseFile, stringify} = require('..')

Expand Down Expand Up @@ -70,3 +72,25 @@ test('it remembers the source path', t => {
'tree.source.path is enumerable')
})
})

test('it creates a tree that works with unist-util-select', t => {
const tree = parse(`
$color: red;
a {
color: $color;
}
`)

remove(tree, 'space')
t.is(select(tree, 'stylesheet')[0], tree)
const firstVariable = tree.children[0].children[0].children[0]
t.is(select(tree, 'declaration variable')[0], firstVariable)
})

test('it adds names to property nodes', t => {
const tree = parse('a { color: green; }', {syntax: 'css'})
const [property] = select(tree, 'property')
t.is(property.name, 'color', 'property lacks name "color"')
const selected = select(tree, 'property[name=color]')
t.deepEqual(selected, [property])
})

0 comments on commit 8002a8b

Please sign in to comment.