From fa7e28369fa4d2724a5794f9851a2a2a831110d0 Mon Sep 17 00:00:00 2001 From: Tieson Trowbridge Date: Thu, 7 Nov 2024 18:16:42 -0500 Subject: [PATCH] Pulls in time regex from MDN --- tests/prompt.test.js | 19 +--- tests/units.html | 205 +++++++++++++++++++++---------------------- 2 files changed, 102 insertions(+), 122 deletions(-) diff --git a/tests/prompt.test.js b/tests/prompt.test.js index 0568840a..e91fa2c2 100644 --- a/tests/prompt.test.js +++ b/tests/prompt.test.js @@ -328,16 +328,6 @@ describe('bootbox.prompt', function () { }); }); - describe('with pattern', function () { - beforeEach(function () { - this.options.pattern = '\d{1,2}/\d{1,2}/\d{4}'; - return this.create(); - }); - return it('has correct pattern value', function () { - return expect(this.find('input[type="text"]').attr('pattern')).to.equal('\d{1,2}/\d{1,2}/\d{4}'); - }); - }); - describe('with maxlength', function () { beforeEach(function () { this.options.maxlength = 5; @@ -435,11 +425,11 @@ describe('bootbox.prompt', function () { }); describe('with pattern', function () { beforeEach(function () { - this.options.pattern = '\d{1,2}/\d{1,2}/\d{4}'; + this.options.pattern = "/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/"; return this.create(); }); return it('has correct pattern value', function () { - return expect(this.find('input[type="email"]').attr('pattern')).to.equal('\d{1,2}/\d{1,2}/\d{4}'); + return expect(this.find('input[type="email"]').attr('pattern')).to.equal("/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/"); }); }); }); @@ -859,11 +849,11 @@ describe('bootbox.prompt', function () { }); describe('with pattern', function () { beforeEach(function () { - this.options.pattern = '\d{1,2}/\d{1,2}/\d{4}'; + this.options.pattern = "(?!00:00)(24:00|([0-1]\d|2[0-3]):[0-5]\d)"; return this.create(); }); return it('has correct pattern value', function () { - return expect(this.find('input[type="time"]').attr('pattern')).to.equal('\d{1,2}/\d{1,2}/\d{4}'); + return expect(this.find('input[type="time"]').attr('pattern')).to.equal("(?!00:00)(24:00|([0-1]\d|2[0-3]):[0-5]\d)"); }); }); describe('with min value', function () { @@ -1062,7 +1052,6 @@ describe('bootbox.prompt', function () { return expect(this.create).to.throw('"step" must be a valid positive number or the value "any". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step for more information.'); }); }); - }); diff --git a/tests/units.html b/tests/units.html index d657037c..77539174 100644 --- a/tests/units.html +++ b/tests/units.html @@ -11,13 +11,13 @@

Unit test results, Grouped

Browser: Chrome Headless 128.0.0.0 (Windows 10)
-
Timestamp: 11/7/2024, 5:51:33 PM
+
Timestamp: 11/7/2024, 6:15:14 PM

- 649 tests / + 648 tests / 0 errors / 0 failures / 0 skipped / - runtime: 0.061s + runtime: 0.066s

@@ -29,7 +29,7 @@

basic usage tests » with no arguments

throws an error regarding argument length

-
Passed in 0.001s
+
Passed in 0s
@@ -47,7 +47,7 @@

basic usage tests » with one argument » where the argument is a string

shows the expected body copy

-
Passed in 0s
+
Passed in 0.001s
@@ -56,7 +56,7 @@

basic usage tests » with one argument » where the argument is a string

shows an OK button

-
Passed in 0.001s
+
Passed in 0.002s
@@ -146,7 +146,7 @@

callback tests » with no callback » when dismissing the dialog by clicking OK

should hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -191,7 +191,7 @@

callback tests » with a simple callback » when dismissing the dialog by clicking OK

should hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -254,7 +254,7 @@

callback tests » with a callback which returns false » when dismissing the dialog by clicking OK

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -290,7 +290,7 @@

callback tests » with a callback which returns false » when clicking the close button

should pass the dialog as "this"

-
Passed in 0s
+
Passed in 0.001s
@@ -338,7 +338,7 @@

is attached to the window object

-
Passed in 0s
+
Passed in 0.001s
@@ -383,7 +383,7 @@

onHide option » hide.bs.modal » when triggered with the correct target

has triggered onHide function

-
Passed in 0.001s
+
Passed in 0s
@@ -437,7 +437,7 @@

If $.fn.modal is undefined » When invoking a dialog

throws the correct error

-
Passed in 0.001s
+
Passed in 0s
@@ -674,7 +674,7 @@

basic usage tests » with two arguments » where the second argument is a function

does not throw an error

-
Passed in 0.001s
+
Passed in 0.002s
@@ -692,7 +692,7 @@

basic usage tests » with two arguments » where the second argument is a function

applies the bootbox-confirm class to the dialog

-
Passed in 0s
+
Passed in 0.001s
@@ -773,7 +773,7 @@

callback tests » with a simple callback » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -791,7 +791,7 @@

callback tests » with a simple callback » when dismissing the dialog by clicking Cancel

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -827,7 +827,7 @@

callback tests » with a simple callback » when triggering the escape event

should invoke the callback

-
Passed in 0s
+
Passed in 0.001s
@@ -854,7 +854,7 @@

callback tests » with a simple callback » when triggering the escape event

should hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -917,7 +917,7 @@

callback tests » with a callback which returns false » when dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -1001,7 +1001,7 @@

animate » when set to true

adds the fade class to the dialog

-
Passed in 0.001s
+
Passed in 0s
@@ -1028,7 +1028,7 @@

size » when set to xl

adds the extra-large class to the innerDialog

-
Passed in 0s
+
Passed in 0.001s
@@ -1109,7 +1109,7 @@

scrollable » when set to true

adds the modal-dialog-scrollable class to the innerDialog

-
Passed in 0.001s
+
Passed in 0s
@@ -1166,7 +1166,7 @@

invalid usage tests » with one argument » where the argument is not an object

throws an error

-
Passed in 0s
+
Passed in 0.002s
@@ -1175,7 +1175,7 @@

invalid usage tests » with one argument » where the argument has no message property

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -1373,7 +1373,7 @@

when creating a dialog with a button » when the button has a label and callback » when clicking the close button

should not invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -1382,7 +1382,7 @@

when creating a dialog with a button » when the button has a label and callback » when clicking the close button

should hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -1391,7 +1391,7 @@

when creating a dialog with a button » when the button has a custom class

shows the correct button text

-
Passed in 0.001s
+
Passed in 0s
@@ -1418,7 +1418,7 @@

when creating a dialog with a button » when the button has no explicit label » when its value is an object

adds the custom class to the button

-
Passed in 0s
+
Passed in 0.001s
@@ -1436,7 +1436,7 @@

when creating a dialog with a button » when the button has no explicit label » when its value is a function » when dismissing the dialog by clicking the button

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -1445,7 +1445,7 @@

when creating a dialog with a button » when the button has no explicit label » when its value is a function » when dismissing the dialog by clicking the button

should pass the dialog as "this"

-
Passed in 0.001s
+
Passed in 0s
@@ -1544,7 +1544,7 @@

when creating a dialog with an onEscape handler » with a simple callback » when triggering the keyup event » when the key is the escape key

should pass the dialog as "this"

-
Passed in 0.001s
+
Passed in 0s
@@ -1562,7 +1562,7 @@

when creating a dialog with an onEscape handler » with a callback which returns false » when triggering the escape keyup event

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -1637,7 +1637,7 @@

Invalid locale

shows the default OK translation

-
Passed in 0.001s
+
Passed in 0s
@@ -1709,7 +1709,7 @@

Azerbaijani

shows the correct CONFIRM translation

-
Passed in 0.001s
+
Passed in 0s
@@ -1736,7 +1736,7 @@

English

shows the correct CONFIRM translation

-
Passed in 0.001s
+
Passed in 0s
@@ -1817,7 +1817,7 @@

Spanish

shows the correct CONFIRM translation

-
Passed in 0s
+
Passed in 0.001s
@@ -1934,7 +1934,7 @@

Russian

shows the correct OK translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2060,7 +2060,7 @@

Danish

shows the correct CONFIRM translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2078,7 +2078,7 @@

Chinese » Taiwan

shows the correct CANCEL translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2141,7 +2141,7 @@

Norwegian

shows the correct CONFIRM translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2195,7 +2195,7 @@

Latvian

shows the correct CONFIRM translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2222,7 +2222,7 @@

Lithuanian

shows the correct CONFIRM translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2312,7 +2312,7 @@

Japanese

shows the correct OK translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2429,7 +2429,7 @@

Thai

shows the correct CANCEL translation

-
Passed in 0.001s
+
Passed in 0s
@@ -2555,7 +2555,7 @@

Slovak

shows the correct OK translation

-
Passed in 0s
+
Passed in 0.001s
@@ -2693,7 +2693,7 @@

basic usage tests » with one argument » where the argument is not an object

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -2756,7 +2756,7 @@

basic usage tests » with one argument » where the argument is an object » with a title and a callback

adds the correct button labels

-
Passed in 0.001s
+
Passed in 0s
@@ -2774,7 +2774,7 @@

basic usage tests » with two arguments » where the second argument is not a function

throws an error requiring a callback

-
Passed in 0s
+
Passed in 0.001s
@@ -2783,7 +2783,7 @@

basic usage tests » with two arguments » where the second argument is a function

does not throw an error

-
Passed in 0.002s
+
Passed in 0.001s
@@ -2873,7 +2873,7 @@

configuration options tests » with `centerVertical` set to `false`

does not add the modal-dialog-centered class to the innerDialog of the prompt

-
Passed in 0s
+
Passed in 0.001s
@@ -2936,7 +2936,7 @@

configuration options tests » setting inputType text » without default value

has proper class

-
Passed in 0s
+
Passed in 0.001s
@@ -2945,7 +2945,7 @@

configuration options tests » setting inputType text » with default value

has correct default value

-
Passed in 0s
+
Passed in 0.001s
@@ -2957,15 +2957,6 @@

Passed in 0s

-
-

-
-

configuration options tests » setting inputType text » with pattern

- has correct pattern value -
-
Passed in 0.001s
-

-

@@ -3107,7 +3098,7 @@

configuration options tests » setting inputType select » without options

throws an error

-
Passed in 0.001s
+
Passed in 0s

@@ -3134,7 +3125,7 @@

configuration options tests » setting inputType select » with options in the wrong format

throws an error

-
Passed in 0.001s
+
Passed in 0s
@@ -3224,7 +3215,7 @@

configuration options tests » setting inputType select » with option groups

with two option group

-
Passed in 0s
+
Passed in 0.001s
@@ -3296,7 +3287,7 @@

configuration options tests » setting inputType radio » with options in the wrong format

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -3404,7 +3395,7 @@

configuration options tests » setting inputType time » with default value

has correct default value

-
Passed in 0s
+
Passed in 0.001s
@@ -3422,7 +3413,7 @@

configuration options tests » setting inputType time » with pattern

has correct pattern value

-
Passed in 0.001s
+
Passed in 0s
@@ -3458,7 +3449,7 @@

configuration options tests » setting inputType time » with an invalid min value

throws an error

-
Passed in 0.001s
+
Passed in 0s
@@ -3503,7 +3494,7 @@

configuration options tests » setting inputType number » without default value

has proper class

-
Passed in 0.001s
+
Passed in 0s
@@ -3530,7 +3521,7 @@

configuration options tests » setting inputType number » with min int value

has correct min value

-
Passed in 0s
+
Passed in 0.001s
@@ -3575,7 +3566,7 @@

configuration options tests » setting inputType number » with step decimal value

has correct step value

-
Passed in 0s
+
Passed in 0.001s
@@ -3602,7 +3593,7 @@

configuration options tests » setting inputType number » with min value greater than max value

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -3656,7 +3647,7 @@

configuration options tests » setting inputType range » with min value

has correct min value

-
Passed in 0s
+
Passed in 0.001s
@@ -3692,7 +3683,7 @@

configuration options tests » setting inputType range » with an invalid max value

throws an error

-
Passed in 0s
+
Passed in 0.001s
@@ -3773,7 +3764,7 @@

callback tests » with a simple callback » when entering no value in the text input » when submitting the form

should hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -3800,7 +3791,7 @@

callback tests » with a simple callback » when entering a value in the text input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -3818,7 +3809,7 @@

callback tests » with a simple callback » when entering a value in the text input » when submitting the form

invokes the callback with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -3863,7 +3854,7 @@

callback tests » with a simple callback » when dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -4016,7 +4007,7 @@

callback tests » with a callback which returns false » when entering a value in the text input » when dismissing the dialog by clicking OK

should not hide the modal

-
Passed in 0s
+
Passed in 0.001s
@@ -4088,7 +4079,7 @@

callback tests » with a callback which returns false » when triggering the escape event

should not hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -4133,7 +4124,7 @@

callback tests » with a default value

populates the input with the default value

-
Passed in 0s
+
Passed in 0.001s
@@ -4160,7 +4151,7 @@

callback tests » with a default value » when entering no value in the text input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -4169,7 +4160,7 @@

callback tests » with a default value » when entering no value in the text input » when dismissing the dialog by clicking Cancel

should invoke the callback

-
Passed in 0s
+
Passed in 0.001s
@@ -4313,7 +4304,7 @@

callback tests » with required: true and default input type » when entering a value in the text input » when dismissing the dialog by clicking OK

should pass the dialog as "this"

-
Passed in 0.001s
+
Passed in 0s
@@ -4322,7 +4313,7 @@

callback tests » with required: true and default input type » when entering a value in the text input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -4529,7 +4520,7 @@

callback tests » with required: true and `password` input type » when entering a value in the text input » when dismissing the dialog by clicking Cancel

should invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -4556,7 +4547,7 @@

callback tests » with required: true and `number` input type

populates the input with the required property

-
Passed in 0.001s
+
Passed in 0s
@@ -4583,7 +4574,7 @@

callback tests » with required: true and `number` input type » when entering no value in the text input » when dismissing the dialog by clicking Cancel

should pass the dialog as "this"

-
Passed in 0.001s
+
Passed in 0s
@@ -4853,7 +4844,7 @@

callback tests » with required: true and `textarea` input type

populates the input with the required property

-
Passed in 0.001s
+
Passed in 0s
@@ -4862,7 +4853,7 @@

callback tests » with required: true and `textarea` input type » when entering no value in the text input » when dismissing the dialog by clicking OK

should not invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -4952,7 +4943,7 @@

callback tests » with inputType select » without a default value

has correct number values in list

-
Passed in 0s
+
Passed in 0.001s
@@ -4979,7 +4970,7 @@

callback tests » with inputType select » without a default value » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -5060,7 +5051,7 @@

callback tests » with inputType select » with a default value » when dismissing the dialog by clicking Cancel

should pass the dialog as "this"

-
Passed in 0s
+
Passed in 0.001s
@@ -5177,7 +5168,7 @@

callback tests » with inputType select » with required: true and no option selected

no option is selected

-
Passed in 0s
+
Passed in 0.001s
@@ -5204,7 +5195,7 @@

callback tests » with inputType select » with required: true and no option selected » when dismissing the dialog by clicking Cancel

should pass the dialog as "this"

-
Passed in 0s
+
Passed in 0.001s
@@ -5240,7 +5231,7 @@

callback tests » with inputType email » without a default value » when dismissing the dialog by clicking OK

should invoke the callback

-
Passed in 0s
+
Passed in 0.001s
@@ -5276,7 +5267,7 @@

callback tests » with inputType email » without a default value » when submitting the form

invokes the callback with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -5348,7 +5339,7 @@

callback tests » with inputType email » with a default value » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -5357,7 +5348,7 @@

callback tests » with inputType email » with a default value » when dismissing the dialog by clicking OK

should hide the modal

-
Passed in 0.001s
+
Passed in 0s
@@ -5393,7 +5384,7 @@

callback tests » with inputType email » with a default value » when changing a value in the email input » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -5501,7 +5492,7 @@

callback tests » with inputType email » with required: true and no default value » when dismissing the dialog by clicking OK

should not invoke the callback

-
Passed in 0.001s
+
Passed in 0s
@@ -5564,7 +5555,7 @@

callback tests » with input type checkbox » without a default value » when dismissing the dialog by clicking OK

with an undefined value

-
Passed in 0s
+
Passed in 0.001s
@@ -5618,7 +5609,7 @@

callback tests » with input type checkbox » with default value » one value checked » when dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -5735,7 +5726,7 @@

callback tests » with input type checkbox » with default value » multiple value checked » when changing the checked options and dismissing the dialog by clicking Cancel

with the correct value

-
Passed in 0s
+
Passed in 0.001s
@@ -5753,7 +5744,7 @@

callback tests » with input type checkbox » with default value » multiple value checked » when changing the checked options and dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s
@@ -5879,7 +5870,7 @@

callback tests » with input type radio » with default value » one value checked » when changing the selected option and dismissing the dialog by clicking OK

with the correct value

-
Passed in 0.001s
+
Passed in 0s