Skip to content

Commit 22bedfb

Browse files
committed
cover the test case where removing a getter with handler, if there is still handler for the getter, do not remove the reference in store.
1 parent eb162a1 commit 22bedfb

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/reactor-fns-tests.js

+34
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,40 @@ describe('reactor fns', () => {
518518
expect(is(expected, result)).toBe(true)
519519
})
520520
})
521+
522+
it('should not remove the getter reference in store when there is still listeners for the getter', () => {
523+
nextObserverState = fns.removeObserver(initialObserverState, getter1, handler2)
524+
const expected = Map({
525+
any: Set.of(getter2),
526+
stores: Map({
527+
store1: Set.of(getter1),
528+
store2: Set.of(getter1),
529+
}),
530+
nextId: 4,
531+
gettersMap: Map([
532+
[getter1, Set.of(1)],
533+
[getter2, Set.of(3)]
534+
]),
535+
observersMap: Map([
536+
[1, Map({
537+
id: 1,
538+
storeDeps: Set.of('store1', 'store2'),
539+
getterKey: getter1,
540+
getter: getter1,
541+
handler: handler1,
542+
})],
543+
[3, Map({
544+
id: 3,
545+
storeDeps: Set(),
546+
getterKey: getter2,
547+
getter: getter2,
548+
handler: handler3,
549+
})]
550+
])
551+
})
552+
const result = nextObserverState
553+
expect(is(expected, result)).toBe(true)
554+
})
521555
})
522556
})
523557
/*eslint-enable one-var, comma-dangle*/

0 commit comments

Comments
 (0)