Skip to content

Commit

Permalink
fix: allow to use customEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Dec 13, 2017
1 parent 92d9e9d commit be22e31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/shallow-equal-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ export const shallowEqualProps = (
console?: Pick<Console, "log" | "group" | "groupEnd">;
}
): boolean => {
const customEqual = options && options.customEqual;
return shallowEqual(propsA, propsB, {
customEqual: isEqualProps,
customEqual: customEqual || isEqualProps,
debug: options && options.debug,
console: options && options.console
});
Expand Down
15 changes: 15 additions & 0 deletions test/shallow-equal-props-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,19 @@ describe("shallow-equal-props", () => {
"elementA is not equal elementB"
);
});
it("pass customEqual", () => {
assert.equal(
shallowEqualProps(
{ a: 1 },
{ a: 2 },
{
customEqual() {
return true;
}
}
),
true,
"should be equal"
);
});
});

0 comments on commit be22e31

Please sign in to comment.