Skip to content

Commit

Permalink
#5377 style VS vdom update order tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiu committed Apr 2, 2024
1 parent 2f35fae commit d376e76
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/components/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import '../../src/button/Base.mjs';
import '../../src/component/DateSelector.mjs';
import '../../src/form/field/ComboBox.mjs';
import '../../src/list/Chip.mjs';
import '../../src/toolbar/Base.mjs';

export const onStart = () => Neo.app({name: 'AppEmpty'})
46 changes: 45 additions & 1 deletion test/components/files/component/Base.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
StartTest(t => {
t.it('Checking colliding vdom updates', async t => {
t.it('Checking colliding style updates', async t => {
const containerId = await Neo.worker.App.createNeoInstance({
ntype : 'container',
height: 250,
Expand Down Expand Up @@ -40,5 +40,49 @@ StartTest(t => {

t.is(document.getElementById(containerId).style.backgroundColor, 'pink');
t.is(document.getElementById(componentId).style.backgroundColor, 'purple');

await Neo.worker.App.destroyNeoInstance(containerId)
});

t.it('Checking colliding vdom updates', async t => {
const toolbarId = await Neo.worker.App.createNeoInstance({
ntype : 'toolbar',
height: 200,
width : 300
});

t.is(toolbarId, 'neo-toolbar-1');

await t.waitForSelector('.neo-toolbar');
t.diag('Toolbar got rendered.');

const buttonId = await Neo.worker.App.createNeoInstance({
ntype : 'button',
parentId: toolbarId,
text : 'hello'
});

t.is(buttonId, 'neo-button-1');

await t.waitForSelector('.neo-button');
t.diag('Button got rendered.');

t.diag('Child update before parent update');
Neo.worker.App.setConfigs({id: buttonId, text : 'world'});
Neo.worker.App.setConfigs({id: toolbarId, height: 300});

await t.waitFor(100);

t.is(document.getElementById(toolbarId).style.height, '300px');
t.is(document.getElementById(buttonId).firstChild.innerHTML, 'world');

t.diag('Parent update before child update');
Neo.worker.App.setConfigs({id: toolbarId, height: 200});
Neo.worker.App.setConfigs({id: buttonId, text : 'hello'});

await t.waitFor(100);

t.is(document.getElementById(toolbarId).style.height, '200px');
t.is(document.getElementById(buttonId).firstChild.innerHTML, 'hello');
});
});

0 comments on commit d376e76

Please sign in to comment.