Skip to content

Not cloning object getters and setters as expected #121

@bertolo1988

Description

@bertolo1988

The following tests should not fail:

 it('should clone a getter', () => {
   const input = {
     a: 2,
     get foo() {
       return this.a * 2
     }
   }
   let clone = func(input)
   assert.ok(clone.foo === 4)
   assert.ok(
     typeof Object.getOwnPropertyDescriptor(clone, 'foo').get === 'function'
   )
 })
 
 
it('should clone a setter', () => {
   const input = {
     set foo(val) {
       this.a = val
     }
   }
   let clone = func(input)
   clone.foo('bar')
   assert.ok(clone.a === 'bar')
   assert.ok(input.a === undefined)
   assert.ok(
     typeof Object.getOwnPropertyDescriptor(clone, 'foo').set === 'function'
   )
 })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions