From 693763e9a419fc336c8bd609f7fd5536d3f20de6 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 24 Jul 2018 14:16:03 -0400 Subject: [PATCH] Add test for unvisited added later siblings Closes GH-13. --- test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test.js b/test.js index e9b520a..54ab4a4 100644 --- a/test.js +++ b/test.js @@ -353,5 +353,26 @@ test('unist-util-visit', function(t) { } ) + t.test('should visit added nodes', function(st) { + var tree = remark().parse('Some _emphasis_, **importance**, and `code`.') + var other = remark().parse('Another ~~sentence~~.').children[0] + var l = types.length + 5 // (p, text, delete, text, text) + var n = 0 + + visit(tree, visitor) + + st.equal(n, l, 'should walk over all nodes') + + st.end() + + function visitor(node, index, parent) { + n++ + + if (n === 2) { + parent.children.push(other) + } + } + }) + t.end() })