Skip to content

Commit

Permalink
tests: Add tests for out of order hypertext children mounting
Browse files Browse the repository at this point in the history
  • Loading branch information
Nefsen402 committed Dec 23, 2024
1 parent 05da25a commit 6055d5a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/replacement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,40 @@ test("static reuse", () => {
}],
});
});

test("mount out of order", () => {
const stuff = Array(4).fill(null).map(() => Observer.mutable(null));

const elem = document.createElement("body");
mount(elem, stuff);

stuff[3].set('4');
stuff[0].set('1');
stuff[2].set('3');
stuff[1].set('2');

assert.deepEqual(elem.tree(), {
name: 'body',
children: ['1', '2', '3', '4'],
});
});

test("mount out of order in div children", () => {
const stuff = Array(4).fill(null).map(() => Observer.mutable(null));

const elem = document.createElement("body");
mount(elem, h('div', {}, ...stuff));

stuff[3].set('4');
stuff[0].set('1');
stuff[2].set('3');
stuff[1].set('2');

assert.deepEqual(elem.tree(), {
name: 'body',
children: [{
name: 'div',
children: ['1', '2', '3', '4'],
}],
});
});

0 comments on commit 6055d5a

Please sign in to comment.