File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
packages/pluggable-widgets-tools/src/utils/__tests__ Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import { WidgetValidationError , throwOnIllegalChars , throwOnNoMatch } from "../validation"
2+
3+ describe ( "Validation Utilities" , ( ) => {
4+
5+ describe ( "throwOnIllegalChars" , ( ) => {
6+
7+ it ( "throws when the input does not match the pattern" , ( ) => {
8+ expect ( throwOnIllegalChars ( "abc" , '0-9' , "Test" ) ) . toThrow ( WidgetValidationError )
9+ } )
10+
11+ it ( "does not throw when the input does match the pattern" , ( ) => {
12+ expect ( throwOnIllegalChars ( "abc" , 'a-z' , "Test" ) ) . not . toThrow ( )
13+ } )
14+ } )
15+
16+ describe ( "throwOnNoMatch" , ( ) => {
17+
18+ it ( "throws when the input does not match the pattern" , ( ) => {
19+ expect ( throwOnNoMatch ( "abc" , / ^ $ / , "Test" ) ) . toThrow ( WidgetValidationError )
20+ } )
21+
22+ it ( "does not throw when the input does match the pattern" , ( ) => {
23+ expect ( throwOnNoMatch ( "abc" , / [ a - z ] / , "Test" ) ) . not . toThrow ( )
24+ } )
25+ } )
26+
27+ } )
28+
You can’t perform that action at this time.
0 commit comments