Skip to content
Snippets Groups Projects
Commit d63b848d authored by Xiao Gui's avatar Xiao Gui
Browse files
parent edb0d8bc
No related branches found
No related tags found
No related merge requests found
import {} from 'jasmine'
import { getGetRegionFromLabelIndexId } from './effect'
import { getGetRegionFromLabelIndexId, UseEffects } from './effect'
import { TestBed } from '@angular/core/testing'
import { Observable } from 'rxjs'
import { SELECT_PARCELLATION, NEWVIEWER, SELECT_REGIONS } from '../state/viewerState.store'
import { provideMockActions } from '@ngrx/effects/testing'
import { hot } from 'jasmine-marbles'
import { provideMockStore } from '@ngrx/store/testing'
import { defaultRootState } from '../stateStore.service'
const colinsJson = require('!json-loader!../../res/ext/colin.json')
const hoc1 = {
name: "Area hOc1 (V1, 17, CalcS) - left hemisphere",
rgb: [
......@@ -34,4 +43,43 @@ describe('effect.ts', () => {
expect(fetchedRegion).toEqual(hoc1)
})
})
describe('UseEffects', () => {
let actions$:Observable<any>
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
UseEffects,
provideMockActions(() => actions$),
provideMockStore({ initialState: defaultRootState })
]
})
const useEffectsInstance: UseEffects = TestBed.get(UseEffects)
useEffectsInstance.onParcellationSelected$.subscribe(console.log)
})
it('both SELECT_PARCELLATION and NEWVIEWER actions should trigger onParcellationSelected$', () => {
const useEffectsInstance: UseEffects = TestBed.get(UseEffects)
actions$ = hot(
'ab',
{
a: { type: SELECT_PARCELLATION },
b: { type: NEWVIEWER }
}
)
expect(
useEffectsInstance.onParcellationSelected$
).toBeObservable(
hot(
'aa',
{
a: { type: SELECT_REGIONS, selectRegions: [] }
}
)
)
})
})
})
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment