Skip to content

Commit

Permalink
Add unit test for listModel.isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Dec 6, 2024
1 parent 2414117 commit 05bf252
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/survey-core/tests/listModelTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ QUnit.test("ListModel custom onFilter", assert => {
ListModel.MINELEMENTCOUNT = oldValueMINELEMENTCOUNT;
});

QUnit.test("ListModel: refresh & isEmpty", assert => {
const items = [
new Action({ id: "test1", title: "test1" }),
new Action({ id: "test2", title: "test2" })
];
const myObject = new MyObject(items);
const list = new ListModel({ items: items, onSelectionChanged: () => { }, allowSelection: true } as any);
assert.equal(list.isEmpty, false, "#1");
list.actions[0].setVisible(false);
list.actions[1].setVisible(false);
list.refresh();
assert.equal(list.isEmpty, true, "#2");
list.actions[1].setVisible(true);
list.refresh();
assert.equal(list.isEmpty, false, "#3");
});

QUnit.test("ListModel custom onFilter: item is not found when a search string contains a white space", assert => {
ListModel.MINELEMENTCOUNT = 5;
const items = [
Expand Down

0 comments on commit 05bf252

Please sign in to comment.