File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,50 @@ describe('Spec Helper', () => {
16
16
expect ( console . warn ) . toHaveBeenCalled ( ) ;
17
17
( < jasmine . Spy > console . warn ) . and . callThrough ( ) ;
18
18
} ) ;
19
+
20
+ describe ( 'string' , ( ) => {
21
+ it ( 'should calculate range for string with maxLength' , ( ) => {
22
+ let schema :any = {
23
+ type : 'string' ,
24
+ maxLength : 3
25
+ } ;
26
+
27
+ SchemaHelper . runInjectors ( schema , schema , '#/' ) ;
28
+ schema . _range . should . be . equal ( '<= 3 characters' ) ;
29
+ } ) ;
30
+
31
+ it ( 'should calculate range for string with minLength' , ( ) => {
32
+ let schema :any = {
33
+ type : 'string' ,
34
+ minLength : 3 ,
35
+ } ;
36
+
37
+ SchemaHelper . runInjectors ( schema , schema , '#/' ) ;
38
+ schema . _range . should . be . equal ( '>= 3 characters' ) ;
39
+ } ) ;
40
+
41
+ it ( 'should calculate range for string with both max and minLength' , ( ) => {
42
+ let schema :any = {
43
+ type : 'string' ,
44
+ minLength : 3 ,
45
+ maxLength : 5
46
+ } ;
47
+
48
+ SchemaHelper . runInjectors ( schema , schema , '#/' ) ;
49
+ schema . _range . should . be . equal ( '[ 3 .. 5 ] characters' ) ;
50
+ } ) ;
51
+
52
+ it ( 'should calculate range for string with equal max and minLength' , ( ) => {
53
+ let schema :any = {
54
+ type : 'string' ,
55
+ minLength : 5 ,
56
+ maxLength : 5
57
+ } ;
58
+
59
+ SchemaHelper . runInjectors ( schema , schema , '#/' ) ;
60
+ schema . _range . should . be . equal ( '5 characters' ) ;
61
+ } ) ;
62
+ } ) ;
19
63
} ) ;
20
64
21
65
describe ( 'preprocessProperties' , ( ) => {
Original file line number Diff line number Diff line change @@ -150,7 +150,11 @@ const injectors = {
150
150
inject : ( injectTo , propertySchema = injectTo ) => {
151
151
var range ;
152
152
if ( propertySchema . minLength != undefined && propertySchema . maxLength != undefined ) {
153
- range = `[ ${ propertySchema . minLength } .. ${ propertySchema . maxLength } ]` ;
153
+ if ( propertySchema . minLength === propertySchema . maxLength ) {
154
+ range = `${ propertySchema . minLength } ` ;
155
+ } else {
156
+ range = `[ ${ propertySchema . minLength } .. ${ propertySchema . maxLength } ]` ;
157
+ }
154
158
} else if ( propertySchema . maxLength != undefined ) {
155
159
range = '<= ' + propertySchema . maxLength ;
156
160
} else if ( propertySchema . minLength != undefined ) {
You can’t perform that action at this time.
0 commit comments