Skip to content

Commit

Permalink
test: add test to cover the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoCardoso committed Sep 9, 2020
1 parent 402cfdd commit 2202ac2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/vaadin-radio-group.html
Expand Up @@ -578,6 +578,34 @@
vaadinRadioButtonGroup._observer.flush();
expect(vaadinRadioButtonGroup.value).to.not.be.equal('2');
});

it('should work if value is set immediately after removing and adding new children', () => {
const items = [
{id: '1', name: 'item_1'},
{id: '2', name: 'item_2'},
{id: '3', name: 'item_3'},
{id: '4', name: 'item_4'}
];
let buttonSelected = 0;
function removeAndAddChildrenAndSelectNext() {
Array.from(vaadinRadioButtonGroup.children).forEach(button => vaadinRadioButtonGroup.removeChild(button));
items.forEach(item => {
const radioButton = window.document.createElement('vaadin-radio-button');
radioButton.textContent = item.name;
radioButton.value = item.id;
vaadinRadioButtonGroup.appendChild(radioButton);
});
vaadinRadioButtonGroup.value = ++buttonSelected;
}

removeAndAddChildrenAndSelectNext();
vaadinRadioButtonGroup._observer.flush();
expect(+vaadinRadioButtonGroup.value).to.be.equal(buttonSelected);

removeAndAddChildrenAndSelectNext();
vaadinRadioButtonGroup._observer.flush();
expect(+vaadinRadioButtonGroup.value).to.be.equal(buttonSelected);
});
});

describe('radio-group-with-dom-repeat', () => {
Expand Down

0 comments on commit 2202ac2

Please sign in to comment.