@@ -262,41 +262,55 @@ describe( 'View', () => {
262262 beforeEach ( createViewWithChildren ) ;
263263
264264 it ( 'should return a promise' , ( ) => {
265- expect ( view . destroy ( ) ) . to . be . instanceof ( Promise ) ;
265+ const promise = view . destroy ( ) ;
266+
267+ expect ( promise ) . to . be . instanceof ( Promise ) ;
268+
269+ return promise ;
270+ } ) ;
271+
272+ it ( 'can be called multiple times' , done => {
273+ expect ( ( ) => {
274+ view . destroy ( ) . then ( ( ) => {
275+ return view . destroy ( ) . then ( ( ) => {
276+ done ( ) ;
277+ } ) ;
278+ } ) ;
279+ } ) . to . not . throw ( ) ;
266280 } ) ;
267281
268- it ( 'should set basic properties null ' , ( ) => {
282+ it ( 'should not touch the basic properties' , ( ) => {
269283 return view . destroy ( ) . then ( ( ) => {
270- expect ( view . element ) . to . be . null ;
271- expect ( view . template ) . to . be . null ;
272- expect ( view . locale ) . to . be . null ;
273- expect ( view . t ) . to . be . null ;
284+ expect ( view . element ) . to . be . an . instanceof ( HTMLElement ) ;
285+ expect ( view . template ) . to . be . an . instanceof ( Template ) ;
286+ expect ( view . locale ) . to . be . an ( 'object' ) ;
287+ expect ( view . locale . t ) . to . be . a ( 'function' ) ;
274288
275- expect ( view . _unboundChildren ) . to . be . null ;
276- expect ( view . _viewCollections ) . to . be . null ;
289+ expect ( view . _viewCollections ) . to . be . instanceOf ( Collection ) ;
290+ expect ( view . _unboundChildren ) . to . be . instanceOf ( ViewCollection ) ;
277291 } ) ;
278292 } ) ;
279293
280- it ( 'clears #_unboundChildren' , ( ) => {
294+ it ( 'should not clear the #_unboundChildren' , ( ) => {
281295 const cached = view . _unboundChildren ;
282296
283297 return view . addChildren ( [ new View ( ) , new View ( ) ] )
284298 . then ( ( ) => {
285- expect ( cached ) . to . have . length . above ( 2 ) ;
299+ expect ( cached ) . to . have . length ( 4 ) ;
286300
287301 return view . destroy ( ) . then ( ( ) => {
288- expect ( cached ) . to . have . length ( 0 ) ;
302+ expect ( cached ) . to . have . length ( 4 ) ;
289303 } ) ;
290304 } ) ;
291305 } ) ;
292306
293- it ( 'clears #_viewCollections' , ( ) => {
307+ it ( 'should not clear the #_viewCollections' , ( ) => {
294308 const cached = view . _viewCollections ;
295309
296310 expect ( cached ) . to . have . length ( 1 ) ;
297311
298312 return view . destroy ( ) . then ( ( ) => {
299- expect ( cached ) . to . have . length ( 0 ) ;
313+ expect ( cached ) . to . have . length ( 1 ) ;
300314 } ) ;
301315 } ) ;
302316
@@ -326,11 +340,15 @@ describe( 'View', () => {
326340 } ) ;
327341
328342 it ( 'destroy a template–less view' , ( ) => {
343+ let promise ;
344+
329345 view = new View ( ) ;
330346
331347 expect ( ( ) => {
332- view . destroy ( ) ;
348+ promise = view . destroy ( ) ;
333349 } ) . to . not . throw ( ) ;
350+
351+ return promise ;
334352 } ) ;
335353
336354 // https://github.com/ckeditor/ckeditor5-ui/issues/203
@@ -383,6 +401,8 @@ function setTestViewClass( templateDef ) {
383401 constructor ( ) {
384402 super ( ) ;
385403
404+ this . locale = { t ( ) { } } ;
405+
386406 if ( templateDef ) {
387407 this . template = new Template ( templateDef ) ;
388408 }
0 commit comments