Skip to content

Commit 0a90f14

Browse files
committed
test: ensure extra fields not be removed
1 parent 8fd0273 commit 0a90f14

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

test/rules/multi.spec.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,29 @@ describe("Test rule: multi", () => {
6363
}
6464
});
6565

66+
v.alias("targetC", {
67+
type: "object", props: {
68+
c: "number"
69+
}
70+
});
71+
6672
const check = v.compile({
6773
$$root: true,
6874
type: "multi",
69-
rules: ["targetA", "targetB"]
75+
rules: ["targetA", "targetB", "targetC"]
7076
});
71-
const oo = {b: 2, c: 3};
7277

7378
expect(check({a: 1})).toBe(true);
7479

75-
expect(check(oo)).toBe(true);
76-
expect(oo).toEqual({b: 2});
80+
const testB = {b: 2, z: 3};
81+
expect(check(testB)).toBe(true);
82+
expect(testB).toEqual({b: 2});
83+
84+
const testC = {c: 3, d: 4};
85+
expect(check(testC)).toBe(true);
86+
expect(testC).toEqual({c: 3, d: 4});
7787

78-
expect(check({c: 3})).toEqual([{"actual": undefined, "field": "a", "message": "The 'a' field is required.", "type": "required"}, {"actual": undefined, "field": "b", "message": "The 'b' field is required.", "type": "required"}]);
88+
expect(check({d: 4})).toEqual([{"actual": undefined, "field": "a", "message": "The 'a' field is required.", "type": "required"}, {"actual": undefined, "field": "b", "message": "The 'b' field is required.", "type": "required"}, {"actual": undefined, "field": "c", "message": "The 'c' field is required.", "type": "required"}]);
7989
});
8090
});
8191
});

0 commit comments

Comments
 (0)