Skip to content

Commit

Permalink
fix: date time testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gkocak-scottlogic authored and ColinEberhardt committed Mar 29, 2023
1 parent 0f1c6c7 commit 376b5d1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions features/support/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ export class ModelSteps extends BaseModelStep {
@then(/the response should have a property ([a-zA-Z]*) with value (.*)/)
public checkResponseProperty(propName: string, propValue: string) {
const value = this.apiResponse.data[propName];
const formattedValue =
value instanceof Date ? value.toISOString() : value.toString();
assert.equal(formattedValue, propValue);
if (value instanceof Date) {
// JS/TS does not differentiate date/date-time. Need to construct prop date and compare.
assert.equal(value.toISOString(), new Date(propValue).toISOString());
} else {
assert.equal(value.toString(), propValue);
}
}

@then(/the response should be an array/)
Expand Down

0 comments on commit 376b5d1

Please sign in to comment.