Skip to content

Commit

Permalink
[Test]: add deep key get when not defined on underlying content
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed May 9, 2021
1 parent d9e54be commit fbd9ce8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,28 @@ describe('Unit | Utility | changeset', () => {
expect((dummyChangeset.users as Array<string>).length).toBe(2);
});

it('#get works if content is undefined for nested key', () => {
class Dog {
breed: string;
constructor(b: string) {
this.breed = b;
}

bark() {
return `woof i'm a ${this.breed}`;
}
}

const model: Record<string, any> = {};

const c = Changeset(model);
c.set('foo.bar.cat', {
color: 'red'
});
const cat = c.get('foo.bar.cat');
expect(cat.color).toEqual('red');
});

/**
* #set
*/
Expand Down

0 comments on commit fbd9ce8

Please sign in to comment.