diff --git a/src/__tests__/index.spec.ts b/src/__tests__/index.spec.ts index 7fd9c97..d9800bc 100644 --- a/src/__tests__/index.spec.ts +++ b/src/__tests__/index.spec.ts @@ -722,43 +722,43 @@ describe('Sakota', () => { it('should merge only upto 2 levels', () => { const entity = { - data: {d1: 'data1'}, + data: { d1: 'data1' }, }; const wrapped = Sakota.create(entity); - const modifier = { $set: { 'links.l1': { id: 'l1' } }}; - spyOn( console, 'warn' ); + const modifier = { $set: { 'links.l1': { id: 'l1' } } }; + spyOn(console, 'warn'); wrapped.__sakota__.mergeChanges(modifier); expect(wrapped).toEqual({ ...entity, links: { l1: { - id: 'l1' - } - } + id: 'l1', + }, + }, } as any); - expect( console.warn ).toHaveBeenCalled(); + expect(console.warn).toHaveBeenCalled(); }); it('throw if the modifier is incorrect', () => { const entity = { - data: {d1: 'data1'}, + data: { d1: 'data1' }, }; const wrapped = Sakota.create(entity); - const modifier = { $set: { 'links.l1.data': 'data1' }}; - spyOn( console, 'warn' ); + const modifier = { $set: { 'links.l1.data': 'data1' } }; + spyOn(console, 'warn'); expect(() => wrapped.__sakota__.mergeChanges(modifier)).toThrow(); - expect( console.warn ).toHaveBeenCalled(); + expect(console.warn).toHaveBeenCalled(); }); it('throw if the modifier is incorrect(2)', () => { const entity = { - data: {d1: 'data1'}, + data: { d1: 'data1' }, }; const wrapped = Sakota.create(entity); - const modifier = { $unset: { 'links.l1': true }}; - spyOn( console, 'warn' ); + const modifier = { $unset: { 'links.l1': true } }; + spyOn(console, 'warn'); expect(() => wrapped.__sakota__.mergeChanges(modifier)).toThrow(); - expect( console.warn ).toHaveBeenCalled(); + expect(console.warn).toHaveBeenCalled(); }); }); @@ -850,7 +850,7 @@ describe('Sakota', () => { // class APoint extends Point {} const obj: any = new Point(); const wrapped = Sakota.create(obj); - wrapped.p = {x: 2, y: 3}; + wrapped.p = { x: 2, y: 3 }; const unwrapped = wrapped.__sakota__.unwrap(); expect(unwrapped).toEqual(new Point(2, 3)); diff --git a/src/index.ts b/src/index.ts index 842dd70..f943956 100644 --- a/src/index.ts +++ b/src/index.ts @@ -463,9 +463,8 @@ export class Sakota implements ProxyHandler { val = Object.assign(this.target, $set); } else { val = Object.assign({}, this.target, $set); - Object.setPrototypeOf( val, Object.getPrototypeOf( this.target )); + Object.setPrototypeOf(val, Object.getPrototypeOf(this.target)); } - } $unset.forEach(k => delete val[k]); return val;