-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for treating NaN values as equivalent (#24)
* add support for treating NaN values as equivalent * Simplify change check --------- Co-authored-by: Jacob Jackson <[email protected]>
- Loading branch information
1 parent
ce20559
commit f46daa0
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { test } from "uvu"; | ||
import * as assert from "uvu/assert"; | ||
import diff from "../dist/index.js"; | ||
|
||
test("new NaN value in object", () => { | ||
assert.equal(diff({}, { testNaN: NaN }), [ | ||
{ | ||
type: "CREATE", | ||
path: ["testNaN"], | ||
value: NaN, | ||
}, | ||
]); | ||
}); | ||
test("change NaN value in object", () => { | ||
assert.equal(diff({ testNaN: NaN }, { testNaN: 0 }), [ | ||
{ | ||
type: "CHANGE", | ||
path: ["testNaN"], | ||
value: 0, | ||
oldValue: NaN, | ||
}, | ||
]); | ||
}); | ||
test("do not change NaN value in object", () => { | ||
assert.equal(diff({ testNaN: NaN }, { testNaN: NaN }), []); | ||
}); | ||
test("remove NaN value in object", () => { | ||
assert.equal(diff({ testNaN: NaN }, {}), [ | ||
{ | ||
type: "REMOVE", | ||
path: ["testNaN"], | ||
oldValue: NaN, | ||
}, | ||
]); | ||
}); | ||
test("new NaN value in array", () => { | ||
assert.equal(diff([], [ NaN ]), [ | ||
{ | ||
type: "CREATE", | ||
path: [0], | ||
value: NaN, | ||
}, | ||
]); | ||
}); | ||
test("change NaN value in object", () => { | ||
assert.equal(diff([ NaN ], [ 0 ]), [ | ||
{ | ||
type: "CHANGE", | ||
path: [0], | ||
value: 0, | ||
oldValue: NaN, | ||
}, | ||
]); | ||
}); | ||
test("do not change NaN value in array", () => { | ||
assert.equal(diff([ NaN ], [ NaN ]), []); | ||
}); | ||
test("remove NaN value in array", () => { | ||
assert.equal(diff([ NaN ], []), [ | ||
{ | ||
type: "REMOVE", | ||
path: [0], | ||
oldValue: NaN, | ||
}, | ||
]); | ||
}); | ||
|
||
test.run(); |