diff --git a/lib/binding_web/test/node-test.js b/lib/binding_web/test/node-test.js index a87658c7..a1011154 100644 --- a/lib/binding_web/test/node-test.js +++ b/lib/binding_web/test/node-test.js @@ -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); + }); + }); });