Skip to content
Prev Previous commit
Next Next commit
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.
  • Loading branch information
lyonlai committed Nov 1, 2015
commit 22bedfba0b9ee481487489908e53503ecbc9842e
34 changes: 34 additions & 0 deletions tests/reactor-fns-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,40 @@ describe('reactor fns', () => {
expect(is(expected, result)).toBe(true)
})
})

it('should not remove the getter reference in store when there is still listeners for the getter', () => {
nextObserverState = fns.removeObserver(initialObserverState, getter1, handler2)
const expected = Map({
any: Set.of(getter2),
stores: Map({
store1: Set.of(getter1),
store2: Set.of(getter1),
}),
nextId: 4,
gettersMap: Map([
[getter1, Set.of(1)],
[getter2, Set.of(3)]
]),
observersMap: Map([
[1, Map({
id: 1,
storeDeps: Set.of('store1', 'store2'),
getterKey: getter1,
getter: getter1,
handler: handler1,
})],
[3, Map({
id: 3,
storeDeps: Set(),
getterKey: getter2,
getter: getter2,
handler: handler3,
})]
])
})
const result = nextObserverState
expect(is(expected, result)).toBe(true)
})
})
})
/*eslint-enable one-var, comma-dangle*/