forked from mcgill-a/unit-testing-with-jest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.ts
33 lines (27 loc) · 790 Bytes
/
component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export interface ColumnHeaderParams {
headerName: string;
api: {
isExpandable: () => boolean;
isExpanded: () => boolean;
setExpanded: (expanded: boolean) => void;
};
}
export interface ColumnHeader {
init(params: ColumnHeaderParams): void;
}
export class CustomColumnHeader implements ColumnHeader {
private params?: ColumnHeaderParams;
public get displayName(): string | undefined {
return this.params?.headerName;
}
public get isExpanded(): boolean {
return !!this.params?.api.isExpanded();
}
public init(params: ColumnHeaderParams): void {
this.params = params;
}
public toggle(): void {
if (!this.params) return;
this.params.api.setExpanded(!this.isExpanded);
}
}