Skip to content
Prev Previous commit
Next Next commit
tests passed
  • Loading branch information
lyonlai committed Nov 1, 2015
commit b75d528224ebcb1276adb251ebc56cef92fc036d
38 changes: 28 additions & 10 deletions tests/reactor-fns-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ describe('reactor fns', () => {
entry = result.entry

})
it('should update the "any" observers', () => {
const expected = Set.of(1)
it('should update the "any" with getter reference', () => {
const expected = Set.of(getter)
const result = nextObserverState.get('any')
expect(is(expected, result)).toBe(true)
})
it('should not update the "store" observers', () => {
it('should not update the "store" with getter reference', () => {
const expected = Map({})
const result = nextObserverState.get('stores')
expect(is(expected, result)).toBe(true)
Expand All @@ -336,6 +336,11 @@ describe('reactor fns', () => {
const result = nextObserverState.get('nextId')
expect(is(expected, result)).toBe(true)
})
it('should update the gettersMap with getter as ref, id as value', () => {
const expected = Set.of(1)
const result = nextObserverState.getIn(['gettersMap', getter])
expect(is(expected, result)).toBe(true)
})
it('should update the observerMap', () => {
const expected = Map([
[1, Map({
Expand Down Expand Up @@ -375,20 +380,25 @@ describe('reactor fns', () => {
nextObserverState = result.observerState
entry = result.entry
})
it('should not update the "any" observers', () => {
it('should not update the "any" getters', () => {
const expected = Set.of()
const result = nextObserverState.get('any')
expect(is(expected, result)).toBe(true)
})
it('should not update the "store" observers', () => {
it('should update the "store" with getter reference', () => {
const expected = Map({
store1: Set.of(1),
store2: Set.of(1),
store1: Set.of(getter),
store2: Set.of(getter),
})

const result = nextObserverState.get('stores')
expect(is(expected, result)).toBe(true)
})
it('should update the gettersMap with getter as ref, id as value', () => {
const expected = Set.of(1)
const result = nextObserverState.getIn(['gettersMap', getter])
expect(is(expected, result)).toBe(true)
})
it('should increment the nextId', () => {
const expected = 2
const result = nextObserverState.get('nextId')
Expand Down Expand Up @@ -448,12 +458,16 @@ describe('reactor fns', () => {
it('should return a new ObserverState with all entries containing the getter removed', () => {
nextObserverState = fns.removeObserver(initialObserverState, getter1)
const expected = Map({
any: Set.of(3),
any: Set.of(getter2),
stores: Map({
store1: Set(),
store2: Set(),
}),
nextId: 4,
gettersMap: Map([
[getter1, Set()],
[getter2, Set.of(3)]
]),
observersMap: Map([
[3, Map({
id: 3,
Expand All @@ -475,10 +489,14 @@ describe('reactor fns', () => {
const expected = Map({
any: Set(),
stores: Map({
store1: Set.of(1, 2),
store2: Set.of(1, 2),
store1: Set.of(getter1),
store2: Set.of(getter1),
}),
nextId: 4,
gettersMap: Map([
[getter1, Set.of(1, 2)],
[getter2, Set()]
]),
observersMap: Map([
[1, Map({
id: 1,
Expand Down