@@ -268,18 +268,6 @@ describe('Schema Object', () => {
268268 ) ;
269269 } ) ;
270270
271- it ( 'warns when array items contain more than 1 entry' , ( ) => {
272- // FIXME support more than one entry :)
273- const schema = new namespace . elements . Object ( {
274- type : [ 'string' , 'number' ] ,
275- } ) ;
276- const parseResult = parse ( context , schema ) ;
277-
278- expect ( parseResult ) . to . contain . warning (
279- "'Schema Object' 'type' more than one type is current unsupported"
280- ) ;
281- } ) ;
282-
283271 it ( 'when type contains a single value' , ( ) => {
284272 const schema = new namespace . elements . Object ( {
285273 type : [ 'string' ] ,
@@ -308,6 +296,44 @@ describe('Schema Object', () => {
308296 expect ( string ) . to . be . instanceof ( namespace . elements . String ) ;
309297 expect ( string . attributes . getValue ( 'typeAttributes' ) ) . to . deep . equal ( [ 'nullable' ] ) ;
310298 } ) ;
299+
300+ it ( 'when type contains multiple values' , ( ) => {
301+ const schema = new namespace . elements . Object ( {
302+ type : [ 'string' , 'number' ] ,
303+ } ) ;
304+ const parseResult = parse ( context , schema ) ;
305+
306+ expect ( parseResult . length ) . to . equal ( 1 ) ;
307+ expect ( parseResult . get ( 0 ) ) . to . be . instanceof ( namespace . elements . DataStructure ) ;
308+ expect ( parseResult ) . to . not . contain . annotations ;
309+
310+ const element = parseResult . get ( 0 ) . content ;
311+ expect ( element ) . to . be . instanceof ( namespace . elements . Enum ) ;
312+
313+ expect ( element . enumerations . length ) . to . equal ( 2 ) ;
314+ expect ( element . enumerations . get ( 0 ) ) . to . be . instanceof ( namespace . elements . String ) ;
315+ expect ( element . enumerations . get ( 1 ) ) . to . be . instanceof ( namespace . elements . Number ) ;
316+ expect ( element . attributes . getValue ( 'typeAttributes' ) ) . to . be . undefined ;
317+ } ) ;
318+
319+ it ( 'when type contains multiple values with null' , ( ) => {
320+ const schema = new namespace . elements . Object ( {
321+ type : [ 'string' , 'number' , 'null' ] ,
322+ } ) ;
323+ const parseResult = parse ( context , schema ) ;
324+
325+ expect ( parseResult . length ) . to . equal ( 1 ) ;
326+ expect ( parseResult . get ( 0 ) ) . to . be . instanceof ( namespace . elements . DataStructure ) ;
327+ expect ( parseResult ) . to . not . contain . annotations ;
328+
329+ const element = parseResult . get ( 0 ) . content ;
330+ expect ( element ) . to . be . instanceof ( namespace . elements . Enum ) ;
331+
332+ expect ( element . enumerations . length ) . to . equal ( 2 ) ;
333+ expect ( element . enumerations . get ( 0 ) ) . to . be . instanceof ( namespace . elements . String ) ;
334+ expect ( element . enumerations . get ( 1 ) ) . to . be . instanceof ( namespace . elements . Number ) ;
335+ expect ( element . attributes . getValue ( 'typeAttributes' ) ) . to . deep . equal ( [ 'nullable' ] ) ;
336+ } ) ;
311337 } ) ;
312338 } ) ;
313339
0 commit comments