Skip to content

Commit

Permalink
test(lens): fix distinct changes test
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyzu committed May 24, 2022
1 parent 0b0047f commit 446247e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
22 changes: 0 additions & 22 deletions packages/core/src/property.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,6 @@ describe('combine', () => {
a.set(undefined)
expect(cb).toHaveBeenCalledTimes(1)
})
it('does not emit if combined property has not change value', () => {
const a = newAtom({ foo: 1, bar: '1' })
const foo = combine(a, (a) => a.foo)
const bar = combine(a, (a) => a.bar)

const fooObserver = {
next: jest.fn(),
}
const barObserver = {
next: jest.fn(),
}
foo.subscribe(fooObserver)
bar.subscribe(barObserver)

a.modify(p => ({ ...p, foo: 2 }))
expect(fooObserver.next).toHaveBeenCalledTimes(1)
expect(barObserver.next).toHaveBeenCalledTimes(0)

a.modify(p => ({ ...p, bar: '2' }))
expect(barObserver.next).toHaveBeenCalledTimes(1)
expect(fooObserver.next).toHaveBeenCalledTimes(1)
})
})

describe('flatten', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/lens/src/lensed-atom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ describe('view', () => {
}
foo.subscribe(fooObserver)
bar.subscribe(barObserver)
// imitate consumer to warm up the cache
foo.get()
bar.get()

foo.set(2)
expect(fooObserver.next).toHaveBeenCalledTimes(1)
Expand Down

0 comments on commit 446247e

Please sign in to comment.