From b8099e69a93877050ebad575b22ea642a82a748b Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Fri, 5 Feb 2021 18:57:54 +0100
Subject: [PATCH] fix unit test

---
 src/ui/parcellationRegion/region.base.spec.ts | 10 ++++++++--
 src/ui/parcellationRegion/region.base.ts      |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/ui/parcellationRegion/region.base.spec.ts b/src/ui/parcellationRegion/region.base.spec.ts
index e70c0f3b9..44695ff6b 100644
--- a/src/ui/parcellationRegion/region.base.spec.ts
+++ b/src/ui/parcellationRegion/region.base.spec.ts
@@ -328,16 +328,22 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 describe('> region.base.ts', () => {
   describe('> regionInOtherTemplateSelector', () => {
 
+    // TODO
+    it('> only selects region in the template specified by selected atlas')
+
     for (const enumKey of Object.keys(EnumParcRegVersion)) {
       describe(`> selector version for ${enumKey}`, () => {
 
         const { mockFetchedTemplates, mr0, mt2, mt0, mp0, mt1, mp1h, mr0lh, mt3, mr0rh } = getRegionInOtherTemplateSelectorBundle(enumKey as EnumParcRegVersion)
 
+        let selectedAtlas = {
+          templateSpaces: mockFetchedTemplates
+        }
         describe('> no hemisphere selected, simulates big brain cyto map', () => {
   
           let result: any[]
           beforeAll(() => {
-            result = regionInOtherTemplateSelector.projector(mockFetchedTemplates, mt0, { region: mr0 })
+            result = regionInOtherTemplateSelector.projector(selectedAtlas, mockFetchedTemplates, mt0, { region: mr0 })
           })
     
           it('> length checks out', () => {
@@ -409,7 +415,7 @@ describe('> region.base.ts', () => {
         describe('> hemisphere data selected (left hemisphere), simulates julich-brain in mni152', () => {
           let result
           beforeAll(() => {
-            result = regionInOtherTemplateSelector.projector(mockFetchedTemplates, mt2, { region: mr0lh })
+            result = regionInOtherTemplateSelector.projector(selectedAtlas, mockFetchedTemplates, mt2, { region: mr0lh })
           })
     
           it('> length checks out', () => {
diff --git a/src/ui/parcellationRegion/region.base.ts b/src/ui/parcellationRegion/region.base.ts
index 0897a5f0c..35c33e9c6 100644
--- a/src/ui/parcellationRegion/region.base.ts
+++ b/src/ui/parcellationRegion/region.base.ts
@@ -261,7 +261,7 @@ export const regionInOtherTemplateSelector = createSelector(
   viewerStateFetchedTemplatesSelector,
   viewerStateSelectedTemplateSelector,
   (atlas, fetchedTemplates, templateSelected, prop) => {
-    const atlasTemplateSpacesIds = atlas.templateSpaces.map(({ ['@id']: id }) => id)
+    const atlasTemplateSpacesIds = atlas.templateSpaces.map(({ ['@id']: id, fullId }) => id || fullId)
     const { region: regionOfInterest } = prop
     const returnArr = []
 
@@ -276,7 +276,7 @@ export const regionInOtherTemplateSelector = createSelector(
     
     const otherTemplates = fetchedTemplates
       .filter(({ fullId }) => getIdFromFullId(fullId) !== selectedTemplateId)
-      .filter(({ ['@id']: id }) => atlasTemplateSpacesIds.includes(id))
+      .filter(({ ['@id']: id, fullId }) => atlasTemplateSpacesIds.includes(id || fullId))
     for (const template of otherTemplates) {
       for (const parcellation of template.parcellations) {
         const flattenedRegions = flattenRegions(parcellation.regions)
-- 
GitLab