Skip to content

Commit

Permalink
expectJSON: improve readability (#3400)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Dec 3, 2021
1 parent 01dfa68 commit cbbff7f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/__testUtils__/expectJSON.ts
Expand Up @@ -24,15 +24,16 @@ function toJSONDeep(value: unknown): unknown {
}

export function expectJSON(actual: unknown) {
const actualJSON = toJSONDeep(actual);

return {
toDeepEqual(expected: unknown) {
expect(toJSONDeep(actual)).to.deep.equal(toJSONDeep(expected));
const expectedJSON = toJSONDeep(expected);
expect(actualJSON).to.deep.equal(expectedJSON);
},
toDeepNestedProperty(path: string, expected: unknown) {
expect(toJSONDeep(actual)).to.deep.nested.property(
path,
toJSONDeep(expected),
);
const expectedJSON = toJSONDeep(expected);
expect(actualJSON).to.deep.nested.property(path, expectedJSON);
},
};
}
Expand Down

0 comments on commit cbbff7f

Please sign in to comment.