|
| 1 | +import { test } from "uvu"; |
| 2 | +import * as assert from "uvu/assert"; |
| 3 | +import diff from "../dist/index.js"; |
| 4 | + |
| 5 | +test("new NaN value in object", () => { |
| 6 | + assert.equal(diff({}, { testNaN: NaN }), [ |
| 7 | + { |
| 8 | + type: "CREATE", |
| 9 | + path: ["testNaN"], |
| 10 | + value: NaN, |
| 11 | + }, |
| 12 | + ]); |
| 13 | +}); |
| 14 | +test("change NaN value in object", () => { |
| 15 | + assert.equal(diff({ testNaN: NaN }, { testNaN: 0 }), [ |
| 16 | + { |
| 17 | + type: "CHANGE", |
| 18 | + path: ["testNaN"], |
| 19 | + value: 0, |
| 20 | + oldValue: NaN, |
| 21 | + }, |
| 22 | + ]); |
| 23 | +}); |
| 24 | +test("do not change NaN value in object", () => { |
| 25 | + assert.equal(diff({ testNaN: NaN }, { testNaN: NaN }), []); |
| 26 | +}); |
| 27 | +test("remove NaN value in object", () => { |
| 28 | + assert.equal(diff({ testNaN: NaN }, {}), [ |
| 29 | + { |
| 30 | + type: "REMOVE", |
| 31 | + path: ["testNaN"], |
| 32 | + oldValue: NaN, |
| 33 | + }, |
| 34 | + ]); |
| 35 | +}); |
| 36 | +test("new NaN value in array", () => { |
| 37 | + assert.equal(diff([], [ NaN ]), [ |
| 38 | + { |
| 39 | + type: "CREATE", |
| 40 | + path: [0], |
| 41 | + value: NaN, |
| 42 | + }, |
| 43 | + ]); |
| 44 | +}); |
| 45 | +test("change NaN value in object", () => { |
| 46 | + assert.equal(diff([ NaN ], [ 0 ]), [ |
| 47 | + { |
| 48 | + type: "CHANGE", |
| 49 | + path: [0], |
| 50 | + value: 0, |
| 51 | + oldValue: NaN, |
| 52 | + }, |
| 53 | + ]); |
| 54 | +}); |
| 55 | +test("do not change NaN value in array", () => { |
| 56 | + assert.equal(diff([ NaN ], [ NaN ]), []); |
| 57 | +}); |
| 58 | +test("remove NaN value in array", () => { |
| 59 | + assert.equal(diff([ NaN ], []), [ |
| 60 | + { |
| 61 | + type: "REMOVE", |
| 62 | + path: [0], |
| 63 | + oldValue: NaN, |
| 64 | + }, |
| 65 | + ]); |
| 66 | +}); |
| 67 | + |
| 68 | +test.run(); |
0 commit comments