Skip to content

Commit ff41661

Browse files
committed
Obtain 100% code coverage
1 parent 054d036 commit ff41661

File tree

10 files changed

+543
-103
lines changed

10 files changed

+543
-103
lines changed

sources/client/src/components/composite-entities-by-kind.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function CompositeEntitiesByKind<E, K>(
3131
const onChangeEntities = (entities: EntitiesSearch.Entities<E>) => {
3232
props.entities.onChange(entities);
3333

34-
if ((entities?.length() ?? 0) <= 0) {
34+
if (entities.length() <= 0) {
3535
dispatch({
3636
type: 'UPDATE_SELECTED_ENTITIES_OPTIONS',
3737
selectedEntitiesOptions: new Set(),

sources/client/src/components/plural-select-control.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function PluralSelectControl(
1010
className?: string;
1111
}
1212
): JSX.Element {
13+
const [selected, setSelected] = React.useState(props.value);
1314
const className = classnames(
1415
props.className,
1516
'wz-select-control',
@@ -24,13 +25,18 @@ export function PluralSelectControl(
2425
<select
2526
multiple
2627
className={className}
27-
value={props?.value?.toArray()}
28+
value={selected.toArray()}
2829
onChange={(event) => {
29-
const values = Array.from(event.target.options)
30-
.filter((option) => option.selected)
31-
.map((option) => option.value);
30+
if (event.target.selectedOptions.length <= 0) {
31+
props.onChange(new Set());
32+
}
3233

33-
props.onChange(new Set(values));
34+
const selectedValues = Array.from(
35+
event.target.selectedOptions
36+
).map((option) => option.value);
37+
38+
setSelected(new Set(selectedValues));
39+
props.onChange(new Set(selectedValues));
3440
}}
3541
>
3642
{props.options.map((option) => (

sources/client/src/vo/set.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,28 @@ export class Set<T> {
5757
return this.#data.slice(-1)[0];
5858
}
5959

60-
public slice(start: number, end: number): Set<T> {
60+
public copy(start: number, end: number): Set<T> {
6161
return new Set(this.#data.slice(start, end));
6262
}
6363

64+
public equals(set: Set<T>): boolean {
65+
if (this.length() !== set.length()) {
66+
return false;
67+
}
68+
69+
if (this === set) {
70+
return true;
71+
}
72+
73+
for (const value of this) {
74+
if (!set.has(value)) {
75+
return false;
76+
}
77+
}
78+
79+
return true;
80+
}
81+
6482
public *[Symbol.iterator]() {
6583
for (const value of this.#data) {
6684
yield value;

0 commit comments

Comments
 (0)