-
Notifications
You must be signed in to change notification settings - Fork 14
Allow custom comparisons of property values #33
Conversation
Codecov Report
@@ Coverage Diff @@
## master #33 +/- ##
==========================================
+ Coverage 98.03% 98.58% +0.54%
==========================================
Files 10 10
Lines 610 705 +95
Branches 137 167 +30
==========================================
+ Hits 598 695 +97
+ Misses 6 4 -2
Partials 6 6
Continue to review full report at Codecov.
|
[ci skip]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor grammar nits
src/support/compare.ts
Outdated
*/ | ||
export interface UnamedConstructRecord { | ||
/** | ||
* Any arguments to pass the constructor function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any arguments to pass the constructor function -> Any arguments to pass to the constructor function ?
src/support/compare.ts
Outdated
@@ -101,14 +148,32 @@ export interface SpliceRecord { | |||
} | |||
|
|||
/** | |||
* A record that describes how to instantiate a new object via a constructor function | |||
* @param Ctor The constructor function | |||
* @param args Any arguments to be passed the constructor function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any arguments to be passed the constructor function -> Any arguments to be passed to the constructor function ?
src/support/d.ts
Outdated
@@ -20,6 +22,20 @@ export function assignProperties(target: WNode | HNode, properties: WidgetProper | |||
} | |||
|
|||
/** | |||
* Creates a function which when placed in an expected render will call the `callback`. If the `callback` returns `true`, the value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creates a function which when placed in an expected render will call the callback
-> Creates a function which, when placed in an expected render, will call the callback
src/support/d.ts
Outdated
@@ -20,6 +22,20 @@ export function assignProperties(target: WNode | HNode, properties: WidgetProper | |||
} | |||
|
|||
/** | |||
* Creates a function which when placed in an expected render will call the `callback`. If the `callback` returns `true`, the value | |||
* of the property is considered equal, otherwise it is considerd not equal and expected render will fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and expected render will fail. -> and the expected render will fail.
[ci skip]
… into feature-complex-compare
src/support/compare.ts
Outdated
prototype: object; | ||
} | ||
|
||
export interface ConstructDescriptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want some tsdoc for this exported interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small doc nit but otherwise looks to add the inline comparison that we need for complex, unknown properties.
to something more logical.
Type: feature
The following has been addressed in the PR:
Description:
This PR adds some features to enable custom comparisons of property values, specifically in
harness.expectRender()
:support/compare/CustomDiff
, allowing the comparison of non-plain objects and custom comparison of primitives.support/compare/diff
andsupport/compare/patch
to support theConstructRecord
which allows for diffing and patching of non-plain Objects.support/d/compareProperty
which wraps a function that returnstrue
orfalse
into aCustomDiff
function.As properties are compared via
diff
, if it encounters aCustomDiff
it will off-load the comparison. In the case of rendering, instead of returning a patch record, theCustomDiff
will simply throw when the test function returnsfalse
indicating the value is unexpected.Resolves #32