Skip to content

Commit e8f6634

Browse files
author
Patricio Albizu
committed
fix: adding details
1 parent effaa25 commit e8f6634

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

projects/components/src/multi-select/multi-select.component.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,18 @@ describe('Multi Select Component', () => {
139139
}));
140140

141141
test('should block prevent default when checkbox is clicked', fakeAsync(() => {
142+
const onChange = jest.fn();
142143
spectator = hostFactory(
143144
`
144-
<ht-multi-select [selected]="selected">
145+
<ht-multi-select (selectedChange)="onChange($event)" [selected]="selected">
145146
<ht-select-option *ngFor="let option of options" [label]="option.label" [value]="option.value">
146147
</ht-select-option>
147148
</ht-multi-select>`,
148149
{
149150
hostProps: {
150151
options: selectionOptions,
151-
selected: []
152+
selected: [],
153+
onChange: onChange
152154
}
153155
}
154156
);
@@ -157,6 +159,11 @@ describe('Multi Select Component', () => {
157159
spectator.click('.trigger-content');
158160
const selectedCheckboxElement = spectator.queryAll('ht-checkbox', { root: true })[0];
159161
expect(spectator.dispatchFakeEvent(selectedCheckboxElement, 'click', true).defaultPrevented).toBe(true);
162+
163+
expect(onChange).toHaveBeenCalledTimes(1);
164+
expect(onChange).toHaveBeenCalledWith([selectionOptions[0].value]);
165+
expect(spectator.query(LabelComponent)?.label).toEqual('first');
166+
flush();
160167
}));
161168

162169
test('should notify and update selection when selection is changed', fakeAsync(() => {

projects/components/src/multi-select/multi-select.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ import { MultiSelectJustify } from './multi-select-justify';
9494
>
9595
<ht-checkbox
9696
class="checkbox"
97-
(click)="preventClickDefault($event)"
97+
(click)="this.preventClickDefault($event)"
9898
[checked]="this.isSelectedItem(item)"
9999
></ht-checkbox>
100100
<ht-icon

0 commit comments

Comments
 (0)