Skip to content
Snippets Groups Projects
Commit 5d602e04 authored by Xiao Gui's avatar Xiao Gui
Browse files

chore: remove rgn in other tmpl

regionInOtherTmpl is already tested in region.base.spec.ts
parent 609566cf
No related branches found
No related tags found
No related merge requests found
......@@ -112,161 +112,5 @@ describe('> regionMenu.component.ts', () => {
const fixture = TestBed.createComponent(RegionMenuComponent)
expect(fixture).toBeTruthy()
})
describe('> regionInOtherTemplatesTmpl', () => {
beforeEach(() => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
viewerStateGetSelectedAtlas,
{ parcellations: [] }
)
})
it('> if selector returns empty array, data-available-in-tmpl-count == 0', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
[]
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.detectChanges()
const toggleBtn = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.AVAILABILITY_IN_OTHER_REF_SPACE}"]`) )
expect(toggleBtn.attributes['data-available-in-tmpl-count']).toEqual('0')
})
it('> if selector returns non empty array, data-available-in-tmpl-count == array.length', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
nohemisphereHrms
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.detectChanges()
const toggleBtn = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.AVAILABILITY_IN_OTHER_REF_SPACE}"]`) )
expect(toggleBtn.attributes['data-available-in-tmpl-count']).toEqual('2')
})
it('> if showRegionInOtherTmpl is set to false, toggle btn will not be shown', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
nohemisphereHrms
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.componentInstance.showRegionInOtherTmpl = false
fixture.detectChanges()
const toggleBtn = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.SHOW_IN_OTHER_REF_SPACE}"]`) )
expect(toggleBtn).toBeFalsy()
})
it('> even if toggleBtn exists, list should be hidden by default', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
nohemisphereHrms
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.detectChanges()
const listContainer = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.SHOW_IN_OTHER_REF_SPACE}"]`) )
expect(listContainer).toBeFalsy()
})
it('> on click of toggle btn, list to become visible', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
nohemisphereHrms
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.detectChanges()
const toggleBtn = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.AVAILABILITY_IN_OTHER_REF_SPACE}"]`) )
toggleBtn.triggerEventHandler('click', null)
fixture.detectChanges()
const listContainer = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.SHOW_IN_OTHER_REF_SPACE}"]`) )
expect(listContainer).toBeTruthy()
})
it('> once list becomes available, there should be 2 items on the list', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
nohemisphereHrms
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.detectChanges()
const toggleBtn = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.AVAILABILITY_IN_OTHER_REF_SPACE}"]`) )
toggleBtn.triggerEventHandler('click', null)
fixture.detectChanges()
const listContainer = fixture.debugElement.queryAll( By.css(`[aria-label="${ARIA_LABELS.SHOW_IN_OTHER_REF_SPACE}"] [role="button"]`) )
expect(listContainer.length).toEqual(2)
})
it('> the text (no hemisphere metadata) on the list is as expected', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
nohemisphereHrms
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.detectChanges()
const toggleBtn = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.AVAILABILITY_IN_OTHER_REF_SPACE}"]`) )
toggleBtn.triggerEventHandler('click', null)
fixture.detectChanges()
const listContainer = fixture.debugElement.queryAll( By.css(`[aria-label="${ARIA_LABELS.SHOW_IN_OTHER_REF_SPACE}"] [role="button"]`) )
// trim white spaces before and after
const texts = listContainer.map(c => c.nativeElement.textContent.replace(/^\s+/, '').replace(/\s+$/, ''))
expect(texts).toContain(mt0.name)
expect(texts).toContain(mt1.name)
})
it('> the text (with hemisphere metadata) on the list is as expected', () => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(
regionInOtherTemplateSelector,
hemisphereMrms
)
const fixture = TestBed.createComponent(RegionMenuComponent)
fixture.componentInstance.region = mr1
fixture.detectChanges()
const toggleBtn = fixture.debugElement.query( By.css(`[aria-label="${ARIA_LABELS.AVAILABILITY_IN_OTHER_REF_SPACE}"]`) )
toggleBtn.triggerEventHandler('click', null)
fixture.detectChanges()
const listContainer = fixture.debugElement.queryAll( By.css(`[aria-label="${ARIA_LABELS.SHOW_IN_OTHER_REF_SPACE}"] [role="button"]`) )
// trim white spaces before and after, and middle white spaces into a single white space
const texts = listContainer.map(c => c.nativeElement.textContent.replace(/^\s+/, '').replace(/\s+$/, '').replace(/\s+/g, ' '))
expect(texts).toContain(`${mt0.name} (left hemisphere)`)
expect(texts).toContain(`${mt1.name} (left hemisphere)`)
})
})
})
})
\ No newline at end of file
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