Skip to content

Commit

Permalink
add additional tests for the selectcheckallcomponent
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickuhlmann committed Nov 25, 2024
1 parent 25cd496 commit 742d565
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
1 change: 1 addition & 0 deletions frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SelectCheckAllComponent>;
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);
});
});
14 changes: 7 additions & 7 deletions frontend/src/app/core/components/select-check-all.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ export class SelectCheckAllComponent {
@Output() changeEvent = new EventEmitter<boolean>();

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
);
}

Expand Down

0 comments on commit 742d565

Please sign in to comment.