Skip to content

Commit 9447fbc

Browse files
committed
update types on example page
1 parent 2a33295 commit 9447fbc

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

packages/demo/src/examples/example07.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type MultipleSelectInstance, multipleSelect } from 'multiple-select-van
33
export default class Example {
44
btnElm?: HTMLButtonElement | null;
55
ms: MultipleSelectInstance[] = [];
6+
ms3?: MultipleSelectInstance;
67

78
mount() {
89
this.ms = multipleSelect('#select1, #select2') as MultipleSelectInstance[];
@@ -12,7 +13,7 @@ export default class Example {
1213
resolve({ '1': 'First', '2': 'Second', '3': 'Third', '4': 'Fourth', '5': 'Fifth' });
1314
});
1415
},
15-
});
16+
}) as MultipleSelectInstance;
1617
this.btnElm = document.querySelector('.submit7');
1718
this.btnElm!.addEventListener('click', this.clickListener);
1819
}
@@ -23,8 +24,8 @@ export default class Example {
2324
// destroy ms instance(s) to avoid DOM leaks
2425
this.ms.forEach(m => m.destroy());
2526
this.ms = [];
26-
this.ms3.destroy();
27-
this.ms = undefined;
27+
this.ms3?.destroy();
28+
this.ms3 = undefined;
2829
}
2930

3031
clickListener = () => {

playwright/e2e/example07.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ test.describe('Example 07 - Submit Data', () => {
2121
let dialogText = '';
2222
page.on('dialog', async (alert) => {
2323
dialogText = alert.message();
24+
console.log('closing')
2425
await alert.dismiss();
2526
});
2627

2728
await page.goto('#/example07');
29+
2830
await page.locator('[data-test=select2].ms-parent').click();
2931
await page.getByRole('option').filter({ hasText: 'Third' }).locator('span').click();
3032
await page.getByRole('option').filter({ hasText: 'Fourth' }).locator('span').click();
@@ -41,5 +43,13 @@ test.describe('Example 07 - Submit Data', () => {
4143
await page.locator('[data-test=select2].ms-parent').click();
4244
await page.getByTestId('submit').click();
4345
await expect(dialogText).toBe('select1=1&select2=1&select2=2');
46+
47+
// select lazy loaded data
48+
await page.waitForTimeout(1);
49+
await page.locator('[data-test=select3].ms-parent').click();
50+
await page.getByRole('option').filter({ hasText: 'First' }).locator('span').click();
51+
await page.locator('[data-test=select3].ms-parent').click();
52+
await page.getByTestId('submit').click();
53+
await expect(dialogText).toBe('select1=1&select2=1&select2=2&select3=1');
4454
});
4555
});

0 commit comments

Comments
 (0)