Skip to content

Commit b75d528

Browse files
committed
tests passed
1 parent 6beea89 commit b75d528

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

tests/reactor-fns-tests.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,12 @@ describe('reactor fns', () => {
321321
entry = result.entry
322322

323323
})
324-
it('should update the "any" observers', () => {
325-
const expected = Set.of(1)
324+
it('should update the "any" with getter reference', () => {
325+
const expected = Set.of(getter)
326326
const result = nextObserverState.get('any')
327327
expect(is(expected, result)).toBe(true)
328328
})
329-
it('should not update the "store" observers', () => {
329+
it('should not update the "store" with getter reference', () => {
330330
const expected = Map({})
331331
const result = nextObserverState.get('stores')
332332
expect(is(expected, result)).toBe(true)
@@ -336,6 +336,11 @@ describe('reactor fns', () => {
336336
const result = nextObserverState.get('nextId')
337337
expect(is(expected, result)).toBe(true)
338338
})
339+
it('should update the gettersMap with getter as ref, id as value', () => {
340+
const expected = Set.of(1)
341+
const result = nextObserverState.getIn(['gettersMap', getter])
342+
expect(is(expected, result)).toBe(true)
343+
})
339344
it('should update the observerMap', () => {
340345
const expected = Map([
341346
[1, Map({
@@ -375,20 +380,25 @@ describe('reactor fns', () => {
375380
nextObserverState = result.observerState
376381
entry = result.entry
377382
})
378-
it('should not update the "any" observers', () => {
383+
it('should not update the "any" getters', () => {
379384
const expected = Set.of()
380385
const result = nextObserverState.get('any')
381386
expect(is(expected, result)).toBe(true)
382387
})
383-
it('should not update the "store" observers', () => {
388+
it('should update the "store" with getter reference', () => {
384389
const expected = Map({
385-
store1: Set.of(1),
386-
store2: Set.of(1),
390+
store1: Set.of(getter),
391+
store2: Set.of(getter),
387392
})
388393

389394
const result = nextObserverState.get('stores')
390395
expect(is(expected, result)).toBe(true)
391396
})
397+
it('should update the gettersMap with getter as ref, id as value', () => {
398+
const expected = Set.of(1)
399+
const result = nextObserverState.getIn(['gettersMap', getter])
400+
expect(is(expected, result)).toBe(true)
401+
})
392402
it('should increment the nextId', () => {
393403
const expected = 2
394404
const result = nextObserverState.get('nextId')
@@ -448,12 +458,16 @@ describe('reactor fns', () => {
448458
it('should return a new ObserverState with all entries containing the getter removed', () => {
449459
nextObserverState = fns.removeObserver(initialObserverState, getter1)
450460
const expected = Map({
451-
any: Set.of(3),
461+
any: Set.of(getter2),
452462
stores: Map({
453463
store1: Set(),
454464
store2: Set(),
455465
}),
456466
nextId: 4,
467+
gettersMap: Map([
468+
[getter1, Set()],
469+
[getter2, Set.of(3)]
470+
]),
457471
observersMap: Map([
458472
[3, Map({
459473
id: 3,
@@ -475,10 +489,14 @@ describe('reactor fns', () => {
475489
const expected = Map({
476490
any: Set(),
477491
stores: Map({
478-
store1: Set.of(1, 2),
479-
store2: Set.of(1, 2),
492+
store1: Set.of(getter1),
493+
store2: Set.of(getter1),
480494
}),
481495
nextId: 4,
496+
gettersMap: Map([
497+
[getter1, Set.of(1, 2)],
498+
[getter2, Set()]
499+
]),
482500
observersMap: Map([
483501
[1, Map({
484502
id: 1,

0 commit comments

Comments
 (0)