add a test

This commit is contained in:
Tom Beckmann 2023-08-03 16:32:51 +02:00
parent b407b5588d
commit b947145e53

View file

@ -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);
});
});
});