From 05bf2525d9bdf733d51786cbc566d082716c8705 Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Fri, 6 Dec 2024 10:53:40 +0200 Subject: [PATCH] Add unit test for listModel.isEmpty --- packages/survey-core/tests/listModelTests.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/survey-core/tests/listModelTests.ts b/packages/survey-core/tests/listModelTests.ts index bbdfe2b953..1bd1ab1438 100644 --- a/packages/survey-core/tests/listModelTests.ts +++ b/packages/survey-core/tests/listModelTests.ts @@ -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 = [