Skip to content

Commit 47bc2da

Browse files
committed
fixed js test file
1 parent 6b37bcd commit 47bc2da

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/rules/string.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ describe("Test rule: string", () => {
5050

5151
it("check pattern", () => {
5252
const check = v.compile({ $$root: true, type: "string", pattern: /^[A-Z]+$/ });
53-
console.log(check("John"));
54-
console.log([{ type: "stringPattern", expected: "/^[A-Z]+$/", actual: "John", message: "The '' field fails to match the required pattern." }]);
53+
5554
expect(check("John")).toEqual([{ type: "stringPattern", expected: "/^[A-Z]+$/", actual: "John", message: "The '' field fails to match the required pattern." }]);
5655
expect(check("JOHN")).toEqual(true);
5756
});
@@ -63,6 +62,13 @@ describe("Test rule: string", () => {
6362
expect(check("JOHN")).toEqual(true);
6463
});
6564

65+
it('check pattern with a quote', () => {
66+
const check = v.compile({ $$root: true, type: 'string', pattern: /^[a-z0-9 .\-'?!":;\\/,_]+$/i });
67+
68+
expect(check('John^')).toEqual([{ field: undefined, type: 'stringPattern', expected: '/^[a-z0-9 .\-\'?!":;\\/,_]+$/i', actual: 'John^', message: 'The \'\' field fails to match the required pattern.' }]);
69+
expect(check('JOHN')).toEqual(true);
70+
});
71+
6672
it("check contains", () => {
6773
const check = v.compile({ $$root: true, type: "string", contains: "bob" });
6874

0 commit comments

Comments
 (0)