-
Notifications
You must be signed in to change notification settings - Fork 72
/
basic.js
56 lines (52 loc) · 1.06 KB
/
basic.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
51
52
53
54
55
56
import { test } from "uvu";
import * as assert from "uvu/assert";
import diff from "../dist/index.js";
test("new raw value", () => {
assert.equal(diff({ test: true }, { test: true, test2: true }), [
{
type: "CREATE",
path: ["test2"],
value: true,
},
]);
});
test("change raw value", () => {
assert.equal(diff({ test: true }, { test: false }), [
{
type: "CHANGE",
path: ["test"],
value: false,
oldValue: true,
},
]);
});
test("remove raw value", () => {
assert.equal(diff({ test: true, test2: true }, { test: true }), [
{
type: "REMOVE",
path: ["test2"],
oldValue: true,
},
]);
});
test("replace object with null", () => {
assert.equal(diff({ object: { test: true } }, { object: null }), [
{
type: "CHANGE",
path: ["object"],
value: null,
oldValue: { test: true },
},
]);
});
test("replace object with other value", () => {
assert.equal(diff({ object: { test: true } }, { object: "string" }), [
{
type: "CHANGE",
path: ["object"],
value: "string",
oldValue: { test: true },
},
]);
});
test.run();