Skip to content

Commit 390f4b1

Browse files
committed
Add graceful failure test
1 parent d73715f commit 390f4b1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/core/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,17 @@ describe("utils", function() {
284284
expect(validatePattern("blue", rxPattern)).toBeFalsy()
285285
})
286286

287-
it("returns a message for invalid pattern'", function() {
287+
it("returns a message for invalid pattern", function() {
288288
expect(validatePattern("pink", rxPattern)).toEqual(errorMessage)
289289
expect(validatePattern("123", rxPattern)).toEqual(errorMessage)
290290
})
291+
292+
it("fails gracefully when an invalid regex value is passed", function() {
293+
expect(() => validatePattern("aValue", "---")).toNotThrow()
294+
expect(() => validatePattern("aValue", 1234)).toNotThrow()
295+
expect(() => validatePattern("aValue", null)).toNotThrow()
296+
expect(() => validatePattern("aValue", [])).toNotThrow()
297+
})
291298
})
292299

293300
describe("validateParam", function() {

0 commit comments

Comments
 (0)