diff --git a/frontend/CHANGELOG.md b/frontend/CHANGELOG.md index 84dc7d2..b56dc01 100644 --- a/frontend/CHANGELOG.md +++ b/frontend/CHANGELOG.md @@ -4,6 +4,7 @@ - feature: multi select for organisations - bugfix: allow multiple query parameters to be set +- bugfix: select check all methods could return 0 instead of a boolean - chore: bump @angular-eslint/eslint-plugin to 18.3.1 - chore: bump typescript-eslint to 8.6.0 - chore: bump @typescript/eslint-plugin to 8.14.0 diff --git a/frontend/src/app/core/components/select-check-all.component.spec.ts b/frontend/src/app/core/components/select-check-all.component.spec.ts new file mode 100644 index 0000000..4f46d23 --- /dev/null +++ b/frontend/src/app/core/components/select-check-all.component.spec.ts @@ -0,0 +1,30 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { SelectCheckAllComponent } from './select-check-all.component'; +import { FormControl } from '@angular/forms'; + +describe('SelectCheckAll', () => { + let fixture: ComponentFixture; + let sut: SelectCheckAllComponent; + + beforeEach(async () => { + TestBed.configureTestingModule({ + imports: [SelectCheckAllComponent], + providers: [], + }).compileComponents(); + + fixture = TestBed.createComponent(SelectCheckAllComponent); + sut = fixture.componentInstance; + sut.model = new FormControl([]); + sut.values = []; + sut.text = 'Alle'; + }); + it('component loaded', () => { + expect(sut).not.toBeNull(); + }); + it('is not checked', () => { + expect(sut.isChecked()).toBe(false); + }); + it('is not indeterminate', () => { + expect(sut.isIndeterminate()).toBe(false); + }); +}); diff --git a/frontend/src/app/core/components/select-check-all.component.ts b/frontend/src/app/core/components/select-check-all.component.ts index e8540ff..7b53fb0 100644 --- a/frontend/src/app/core/components/select-check-all.component.ts +++ b/frontend/src/app/core/components/select-check-all.component.ts @@ -30,19 +30,19 @@ export class SelectCheckAllComponent { @Output() changeEvent = new EventEmitter(); isChecked(): boolean { - return ( + return Boolean( this.model.value && - this.values.length && - this.model.value.length === this.values.length + this.values.length && + this.model.value.length === this.values.length ); } isIndeterminate(): boolean { - return ( + return Boolean( this.model.value && - this.values.length && - this.model.value.length && - this.model.value.length < this.values.length + this.values.length && + this.model.value.length && + this.model.value.length < this.values.length ); }