|
1 | 1 | /* eslint-disable @typescript-eslint/no-explicit-any */
|
2 |
| -import { createCheckBox } from './../src/common/common'; |
| 2 | +import { ChangeEventArgs, createCheckBox } from './../src/common/common'; |
3 | 3 | import { CheckBox } from './../src/check-box/check-box';
|
4 | 4 | import { createElement, EventHandler, attributes, enableRipple } from '@syncfusion/ej2-base';
|
5 | 5 | import { profile , inMB, getMemoryProfile } from './common.spec';
|
@@ -428,6 +428,7 @@ describe('CheckBox', () => {
|
428 | 428 | let formElement: HTMLFormElement;
|
429 | 429 | let cbox: CheckBox;
|
430 | 430 | let cbox1: CheckBox;
|
| 431 | + let cbox3: CheckBox; |
431 | 432 |
|
432 | 433 | beforeEach(() => {
|
433 | 434 |
|
@@ -455,6 +456,14 @@ describe('CheckBox', () => {
|
455 | 456 | checkbox.checked = true; // Set the checkbox to checked
|
456 | 457 | checkbox.dataBind();
|
457 | 458 | });
|
| 459 | + |
| 460 | + let button = document.createElement('button'); |
| 461 | + button.setAttribute('id', 'cbox3'); |
| 462 | + document.body.appendChild(button); |
| 463 | + button.addEventListener('click', () => { |
| 464 | + cbox3.checked = !cbox3.checked; |
| 465 | + cbox3.dataBind(); |
| 466 | + }); |
458 | 467 | })
|
459 | 468 |
|
460 | 469 | afterEach(() => {
|
@@ -521,6 +530,25 @@ describe('CheckBox', () => {
|
521 | 530 | expect(checkbox.element.checked).toBe(false);
|
522 | 531 | checkbox.isVue = false;
|
523 | 532 | });
|
| 533 | + |
| 534 | + it('95768-Checkbox not getting checked while using usestate', () => { |
| 535 | + let isChecked = false; |
| 536 | + cbox3 = new CheckBox({ |
| 537 | + checked: isChecked, |
| 538 | + change: (e: ChangeEventArgs) => { |
| 539 | + isChecked = e.checked; |
| 540 | + checkbox.dataBind(); |
| 541 | + } |
| 542 | + }, '#checkbox3'); |
| 543 | + let button = document.querySelector('#cbox3') as HTMLButtonElement; |
| 544 | + button.click(); |
| 545 | + expect(cbox3.checked).toBeTruthy(); |
| 546 | + expect(cbox3.element.checked).toBe(true); |
| 547 | + button = document.querySelector('#cbox3') as HTMLButtonElement; |
| 548 | + button.click(); |
| 549 | + expect(cbox3.checked).toBeFalsy(); |
| 550 | + expect(cbox3.element.checked).toBe(false); |
| 551 | + }); |
524 | 552 | });
|
525 | 553 |
|
526 | 554 | describe('Notify Html Attributes property changes of', () => {
|
|
0 commit comments