@@ -211,6 +211,36 @@ describe("Component.create", function () {
211211 } ) ;
212212 } ) ;
213213
214+ describe ( "type in second argument (more)" , function ( ) {
215+ it ( "should create instance of type specified in second argument" , function ( ) {
216+ const result = TestWidget . create ( { text : "hello" } , { type : TestButton } ) ;
217+ assert . ok ( result instanceof TestButton ) ;
218+ assert . equal ( result . text , "hello" ) ;
219+ } ) ;
220+
221+ it ( "should create instance of $type specified in second argument" , function ( ) {
222+ const result = TestWidget . create ( { text : "world" } , { $type : TestButton } ) ;
223+ assert . ok ( result instanceof TestButton ) ;
224+ assert . equal ( result . text , "world" ) ;
225+ } ) ;
226+
227+ it ( "should work when first argument is an array and second has type" , function ( ) {
228+ const results = Component . create ( [ { text : "A" } , { text : "B" } ] , { type : TestButton } ) ;
229+ assert . equal ( results . length , 2 ) ;
230+ assert . ok ( results [ 0 ] instanceof TestButton ) ;
231+ assert . ok ( results [ 1 ] instanceof TestButton ) ;
232+ assert . equal ( results [ 0 ] . text , "A" ) ;
233+ assert . equal ( results [ 1 ] . text , "B" ) ;
234+ } ) ;
235+
236+ it ( "should work when type is passed as first arg with array config and type in more" , function ( ) {
237+ const results = Component . create ( TestWidget , [ { text : "X" } ] , { type : TestButton } ) ;
238+ assert . equal ( results . length , 1 ) ;
239+ assert . ok ( results [ 0 ] instanceof TestButton ) ;
240+ assert . equal ( results [ 0 ] . text , "X" ) ;
241+ } ) ;
242+ } ) ;
243+
214244 describe ( "heterogeneous array with type property" , function ( ) {
215245 it ( "creates array of different component types" , function ( ) {
216246 const results = Component . create ( [
0 commit comments