diff --git a/src/ui/parcellationRegion/regionMenu/regionMenu.component.spec.ts b/src/ui/parcellationRegion/regionMenu/regionMenu.component.spec.ts index fceeb0c7046afe38195967825e12cbd82097dde2..3c7f395eece740396746c2e452f9f9061490736b 100644 --- a/src/ui/parcellationRegion/regionMenu/regionMenu.component.spec.ts +++ b/src/ui/parcellationRegion/regionMenu/regionMenu.component.spec.ts @@ -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