nlcst-test
nlcst utility to assert trees.
Install
npm:
npm install nlcst-test
Use
var assert = require('nlcst-test')
assert({type: 'RootNode', children: []})
assert({type: 'SourceNode', value: 'fn()'})
assert({type: 'WordNode', children: [{type: 'TextNode', value: 'Hi'}]})
// All OK.
assert({children: []})
// AssertionError: node should have a type: `{ children: [] }`
assert({type: 'WordNode', value: 'foo'})
// AssertionError: parent should have children: `{ type: 'WordNode', value: 'foo' }`
API
assert(tree)
Assert that tree
is a valid nlcst node. If tree
is a parent, all children will be asserted as well.
The assert.parent
, assert.text
, assert.void
, and assert.wrap
methods from unist-util-assert
are also included.
Related
unist-util-assert
— assert unist treesmdast-util-assert
— Assert mdast treeshast-util-assert
— assert hast trees
Contribute
See contributing.md
in syntax-tree/.github
for ways to get started. See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.