add a test
This commit is contained in:
parent
b407b5588d
commit
b947145e53
1 changed files with 16 additions and 0 deletions
|
|
@ -454,4 +454,20 @@ describe("Node", () => {
|
|||
assert(!node1.equals(node2));
|
||||
});
|
||||
});
|
||||
|
||||
describe('.fieldNameForChild(index)', () => {
|
||||
it('returns the field of a child or null', () => {
|
||||
tree = parser.parse('let a = 5');
|
||||
|
||||
const noField = tree.rootNode.fieldNameForChild(0);
|
||||
const name = tree.rootNode.firstChild.children[1].fieldNameForChild(0);
|
||||
const value = tree.rootNode.firstChild.children[1].fieldNameForChild(2);
|
||||
const overflow = tree.rootNode.firstChild.children[1].fieldNameForChild(3);
|
||||
|
||||
assert.equal(noField, null);
|
||||
assert.equal(name, 'name');
|
||||
assert.equal(value, 'value');
|
||||
assert.equal(overflow, null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue