This repository was archived by the owner on Sep 21, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ module.exports = class BrowserRunner extends Runner {
3030 . map ( ( suite ) => {
3131 if ( suite . hasOwnProperty ( 'url' ) ) {
3232 Object . defineProperty ( suite , 'fullUrl' , {
33+ enumerable : true ,
3334 get : ( ) => this . _mkFullUrl ( suite . url )
3435 } ) ;
3536 }
Original file line number Diff line number Diff line change @@ -84,7 +84,8 @@ module.exports = class Suite {
8484 const clonedSuite = Suite . create ( this . name , this . parent ) ;
8585
8686 _ . forOwn ( this , ( value , key ) => {
87- clonedSuite [ key ] = _ . clone ( value ) ;
87+ let desc = Object . getOwnPropertyDescriptor ( this , key ) ;
88+ Object . defineProperty ( clonedSuite , key , _ . cloneDeep ( desc ) ) ;
8889 } ) ;
8990
9091 this . children . forEach ( ( child ) => clonedSuite . addChild ( child . clone ( ) ) ) ;
Original file line number Diff line number Diff line change @@ -342,9 +342,26 @@ describe('suite', () => {
342342
343343 it ( 'should return cloned suite' , ( ) => {
344344 const suite = createSuite ( 'origin' ) ;
345+ suite . browsers = [ 'bro1' , 'bro2' ] ;
345346 const clonedSuite = suite . clone ( ) ;
346347
347- assert . notEqual ( clonedSuite , suite ) ;
348+ assert . deepEqual ( clonedSuite , suite ) ;
349+ assert . notEqual ( clonedSuite , suite ) ; //not equal by link
350+ assert . notEqual ( clonedSuite . browsers , suite . browsers ) ; //not equal by link
351+ } ) ;
352+
353+ it ( 'should clone all enumerable properties' , ( ) => {
354+ const suite = createSuite ( 'origin' ) ;
355+ let value = 'some/path' ;
356+ Object . defineProperty ( suite , 'fullUrl' , {
357+ enumerable : true ,
358+ get : ( ) => value
359+ } ) ;
360+ const clonedSuite = suite . clone ( ) ;
361+
362+ assert . equal ( clonedSuite . fullUrl , 'some/path' ) ;
363+ value = 'another/path' ;
364+ assert . equal ( clonedSuite . fullUrl , 'another/path' ) ;
348365 } ) ;
349366
350367 it ( 'should clone nested suites' , ( ) => {
You can’t perform that action at this time.
0 commit comments