@@ -81,6 +81,93 @@ describe('Schema builder', () => {
8181 nullable : false
8282 } ) ;
8383 } ) ;
84+ describe ( 'Schema.array' , ( ) => {
85+ it ( 'builds an array schema with basic items' , ( ) => {
86+ const schema = Schema . array ( {
87+ items : Schema . string ( )
88+ } ) ;
89+ expect ( schema . toJSON ( ) ) . to . eql ( {
90+ type : 'array' ,
91+ nullable : false ,
92+ items : {
93+ type : 'string' ,
94+ nullable : false
95+ }
96+ } ) ;
97+ } ) ;
98+
99+ it ( 'builds an array schema with items and minItems' , ( ) => {
100+ const schema = Schema . array ( {
101+ items : Schema . number ( ) ,
102+ minItems : 1
103+ } ) ;
104+ expect ( schema . toJSON ( ) ) . to . eql ( {
105+ type : 'array' ,
106+ nullable : false ,
107+ items : {
108+ type : 'number' ,
109+ nullable : false
110+ } ,
111+ minItems : 1
112+ } ) ;
113+ } ) ;
114+
115+ it ( 'builds an array schema with items and maxItems' , ( ) => {
116+ const schema = Schema . array ( {
117+ items : Schema . boolean ( ) ,
118+ maxItems : 10
119+ } ) ;
120+ expect ( schema . toJSON ( ) ) . to . eql ( {
121+ type : 'array' ,
122+ nullable : false ,
123+ items : {
124+ type : 'boolean' ,
125+ nullable : false
126+ } ,
127+ maxItems : 10
128+ } ) ;
129+ } ) ;
130+
131+ it ( 'builds an array schema with items, minItems, and maxItems' , ( ) => {
132+ const schema = Schema . array ( {
133+ items : Schema . integer ( ) ,
134+ minItems : 0 ,
135+ maxItems : 5
136+ } ) ;
137+ expect ( schema . toJSON ( ) ) . to . eql ( {
138+ type : 'array' ,
139+ nullable : false ,
140+ items : {
141+ type : 'integer' ,
142+ nullable : false
143+ } ,
144+ minItems : 0 ,
145+ maxItems : 5
146+ } ) ;
147+ } ) ;
148+
149+ it ( 'builds an array schema with items, minItems, maxItems, and other options' , ( ) => {
150+ const schema = Schema . array ( {
151+ items : Schema . string ( { description : 'A list of names' } ) ,
152+ minItems : 1 ,
153+ maxItems : 3 ,
154+ nullable : true ,
155+ description : 'An array of strings'
156+ } ) ;
157+ expect ( schema . toJSON ( ) ) . to . eql ( {
158+ type : 'array' ,
159+ nullable : true ,
160+ description : 'An array of strings' ,
161+ items : {
162+ type : 'string' ,
163+ description : 'A list of names' ,
164+ nullable : false
165+ } ,
166+ minItems : 1 ,
167+ maxItems : 3
168+ } ) ;
169+ } ) ;
170+ } ) ;
84171 it ( 'builds an object schema' , ( ) => {
85172 const schema = Schema . object ( {
86173 properties : {
0 commit comments