unified

Project:syntax-tree/nlcst-test

Package:nlcst-test@2.0.0

  1. Dependencies:3·Dependents:0
  2. nlcst utility to check assert an nlcst node
  1. util 105
  2. utility 105
  3. unist 90
  4. nlcst 13
  5. check 9
  6. nlcst-util 8
  7. test 6
  8. assert 4

nlcst-test

Build Coverage Downloads Size Sponsors Backers Chat

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.

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.

License

MIT © Titus Wormer