deno.land / x / microdiff@v1.4.0 / tests / arrays.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import test from "node:test";import assert from "node:assert";import diff from "../dist/index.js";
test("top level array & array diff", () => { assert.deepStrictEqual(diff(["test", "testing"], ["test"]), [ { type: "REMOVE", path: [1], oldValue: "testing", }, ]);});
test("nested array", () => { assert.deepStrictEqual( diff(["test", ["test"]], ["test", ["test", "test2"]]), [ { type: "CREATE", path: [1, 1], value: "test2", }, ], );});
test("object in array in object", () => { assert.deepStrictEqual( diff( { test: ["test", { test: true }] }, { test: ["test", { test: false }] }, ), [ { type: "CHANGE", path: ["test", 1, "test"], value: false, oldValue: true, }, ], );});
test("array to object", () => { assert.deepStrictEqual(diff({ data: [] }, { data: { val: "test" } }), [ { type: "CHANGE", path: ["data"], value: { val: "test" }, oldValue: [] }, ]);});
microdiff

Version Info

Tagged at
2 months ago