Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterEvarior committed Nov 15, 2024
1 parent 59b201f commit 3bcc769
Showing 1 changed file with 1 addition and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,43 +104,14 @@ describe('CheckInFormComponent', () => {
id: checkInMetric.id,
version: checkInMetric.version,
confidence: checkInMetric.confidence,
value: checkInMetric.value,
value: checkInMetric.value!.toString(),
changeInfo: checkInMetric.changeInfo,
initiatives: checkInMetric.initiatives,
keyResultId: keyResultMetric.id,
});
expect(actionServiceMock.updateActions).toHaveBeenCalled();
}));

it.each([
['HelloWorld200', 200],
['200HelloWorld', 200],
["200'000", 200000],
['1050&%ç*', 1050],
])('should parse value %s correctly to %s if key result is metric', (value: string, expected: number) => {
component.checkIn = checkInMetric;
component.keyResult = keyResultMetric;
component.dialogForm.controls['value'].setValue(value);
component.dialogForm.controls['confidence'].setValue(checkInMetric.confidence);
component.dialogForm.controls['changeInfo'].setValue(checkInMetric.changeInfo);
component.dialogForm.controls['initiatives'].setValue(checkInMetric.initiatives);

checkInServiceMock.saveCheckIn.mockReturnValue(of(checkInMetric));
actionServiceMock.updateActions.mockReturnValue(of(action2));
component.saveCheckIn();

expect(checkInServiceMock.saveCheckIn).toHaveBeenCalledWith({
id: checkInMetric.id,
version: checkInMetric.version,
confidence: checkInMetric.confidence,
value: expected,
changeInfo: checkInMetric.changeInfo,
initiatives: checkInMetric.initiatives,
keyResultId: keyResultMetric.id,
});
expect(actionServiceMock.updateActions).toHaveBeenCalled();
});

it('should save check-in correctly if key result is ordinal', waitForAsync(async () => {
component.checkIn = checkInOrdinal;
component.keyResult = keyResultOrdinal;
Expand Down

0 comments on commit 3bcc769

Please sign in to comment.