Skip to content

Commit

Permalink
Add unit tests for method preservation
Browse files Browse the repository at this point in the history
  • Loading branch information
magneticflux- committed May 4, 2020
1 parent ed90067 commit ecc4987
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/focal/test/lens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,26 @@ describe('property expressions', () => {
process.env.NODE_ENV = originalNodeEnv
})
})
describe('object', () => {
class TestObject {
constructor(public num: number) {
}
getNum(): number {
return this.num
}
}
let o1 = new TestObject(0)
const l1 = Lens.key<TestObject>()('num')

it('num lens', () => expect(l1.get(o1)).toEqual(0))
it('num property', () => expect(o1.num).toEqual(0))

describe('after lens set', () => {
beforeEach(() => {
o1 = l1.set(10, o1)
})
it('num lens', () => expect(l1.get(o1)).toEqual(10))
it('num property', () => expect(o1.num).toEqual(10))
it('getNum method', () => expect(o1.getNum()).toEqual(10))
})
})

0 comments on commit ecc4987

Please sign in to comment.