@@ -180,6 +180,18 @@ describe('TypedProps', function() {
180
180
should ( report [ 0 ] . rule ) . be . equal ( 'type' )
181
181
should ( report [ 0 ] . details . type ) . be . equal ( 'object' )
182
182
} )
183
+
184
+ it ( 'Should not pass not an array' , function ( ) {
185
+ const value = [ ]
186
+
187
+ const type = Type . object
188
+
189
+ const report = check ( value , type )
190
+
191
+ should ( report ) . has . lengthOf ( 1 )
192
+ should ( report [ 0 ] . rule ) . be . equal ( 'type' )
193
+ should ( report [ 0 ] . details . type ) . be . equal ( 'object' )
194
+ } )
183
195
} )
184
196
185
197
describe ( '.array' , function ( ) {
@@ -203,7 +215,7 @@ describe('TypedProps', function() {
203
215
should ( report ) . has . lengthOf ( 0 )
204
216
} )
205
217
206
- it ( 'Should not pass not array' , function ( ) {
218
+ it ( 'Should not pass not an array' , function ( ) {
207
219
const value = null
208
220
209
221
const type = Type . array
@@ -214,6 +226,18 @@ describe('TypedProps', function() {
214
226
should ( report [ 0 ] . rule ) . be . equal ( 'type' )
215
227
should ( report [ 0 ] . details . type ) . be . equal ( 'array' )
216
228
} )
229
+
230
+ it ( 'Should not pass an object' , function ( ) {
231
+ const value = { }
232
+
233
+ const type = Type . array
234
+
235
+ const report = check ( value , type )
236
+
237
+ should ( report ) . has . lengthOf ( 1 )
238
+ should ( report [ 0 ] . rule ) . be . equal ( 'type' )
239
+ should ( report [ 0 ] . details . type ) . be . equal ( 'array' )
240
+ } )
217
241
} )
218
242
219
243
describe ( '.func' , function ( ) {
@@ -572,6 +596,21 @@ describe('TypedProps', function() {
572
596
should ( report [ 0 ] . details . type ) . be . equal ( 'object' )
573
597
} )
574
598
599
+ it ( 'Should not treat an array as an object' , function ( ) {
600
+ const value = [ 0 , 1 ] ;
601
+
602
+ const type = Type . shape ( {
603
+ 0 : Type . number ,
604
+ 1 : Type . string ,
605
+ } )
606
+
607
+ const report = check ( value , type )
608
+
609
+ should ( report ) . has . lengthOf ( 1 )
610
+ should ( report [ 0 ] . rule ) . be . equal ( 'type' )
611
+ should ( report [ 0 ] . details . type ) . be . equal ( 'object' )
612
+ } )
613
+
575
614
it ( 'Should check an array' , function ( ) {
576
615
const value = [ null , null ]
577
616
@@ -590,6 +629,21 @@ describe('TypedProps', function() {
590
629
should ( report [ 1 ] . details . type ) . be . equal ( 'string' )
591
630
} )
592
631
632
+ it ( 'Should not treat an object as an array' , function ( ) {
633
+ const value = { 0 : 0 , 1 : '1' }
634
+
635
+ const type = Type . shape ( [
636
+ Type . number ,
637
+ Type . string ,
638
+ ] )
639
+
640
+ const report = check ( value , type )
641
+
642
+ should ( report ) . has . lengthOf ( 1 )
643
+ should ( report [ 0 ] . rule ) . be . equal ( 'type' )
644
+ should ( report [ 0 ] . details . type ) . be . equal ( 'array' )
645
+ } )
646
+
593
647
it ( 'Should not pass incorrect' , function ( ) {
594
648
const value = {
595
649
one : 1 ,
0 commit comments