Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
siibra-explorer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiao Gui
siibra-explorer
Commits
2771caf4
Commit
2771caf4
authored
4 years ago
by
Xiao Gui
Browse files
Options
Downloads
Patches
Plain Diff
chore: add tests to new ...
... regionInOtherTemplateSelector beahviour
parent
69767589
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ui/parcellationRegion/region.base.spec.ts
+401
-212
401 additions, 212 deletions
src/ui/parcellationRegion/region.base.spec.ts
with
401 additions
and
212 deletions
src/ui/parcellationRegion/region.base.spec.ts
+
401
−
212
View file @
2771caf4
...
...
@@ -2,83 +2,9 @@ import { TestBed } from '@angular/core/testing'
import
{
MockStore
,
provideMockStore
}
from
'
@ngrx/store/testing
'
import
{
RegionBase
,
regionInOtherTemplateSelector
,
getRegionParentParcRefSpace
}
from
'
./region.base
'
const
mr1wrong
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
fff-bbb
'
}
}
}
const
mr0wrong
=
{
labelIndex
:
1
,
name
:
'
mr0
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-fff
'
}
}
}
const
mr1lh
=
{
labelIndex
:
1
,
name
:
'
mr1 - left hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
const
mr1rh
=
{
labelIndex
:
1
,
name
:
'
mr1 - right hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
const
mr0lh
=
{
labelIndex
:
1
,
name
:
'
mr0 - left hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-bbb
'
}
}
}
const
mr0rh
=
{
labelIndex
:
1
,
name
:
'
mr0 - right hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-bbb
'
}
}
}
const
mr1
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
/**
* regions
*/
const
mr0
=
{
labelIndex
:
1
,
...
...
@@ -91,164 +17,427 @@ const mr0 = {
}
}
// parcellations
const
mp1h
=
{
name
:
'
mp1h
'
,
regions
:
[
mr1lh
,
mr0lh
,
mr0rh
,
mr1rh
]
enum
EnumParcRegVersion
{
V1_18
=
'
V1_18
'
,
V2_4
=
"
V2_4
"
}
const
mpWrong
=
{
name
:
'
mp1h
'
,
regions
:
[
mr1wrong
,
mr0wrong
]
}
const
mp0
=
{
name
:
'
mp0
'
,
regions
:
[
mr1
,
mr0
]
}
// templates
const
getRegionInOtherTemplateSelectorBundle
=
(
version
:
EnumParcRegVersion
)
=>
{
switch
(
version
)
{
case
EnumParcRegVersion
.
V1_18
:
{
/**
* regions
*/
const
mr1wrong
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
fff-bbb
'
}
}
}
const
mr0wrong
=
{
labelIndex
:
1
,
name
:
'
mr0
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-fff
'
}
}
}
const
mt0
=
{
name
:
'
mt0
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/aaa-bbb
'
,
parcellations
:
[
mp0
]
}
const
mt1
=
{
name
:
'
mt1
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/bbb-bbb
'
,
parcellations
:
[
mp0
]
}
const
mr1lh
=
{
labelIndex
:
1
,
name
:
'
mr1 - left hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
const
mr1rh
=
{
labelIndex
:
1
,
name
:
'
mr1 - right hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
const
mr0lh
=
{
labelIndex
:
1
,
name
:
'
mr0 - left hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-bbb
'
}
}
}
const
mr0rh
=
{
labelIndex
:
1
,
name
:
'
mr0 - right hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-bbb
'
}
}
}
const
mr1
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
// parcellations
const
mp1h
=
{
name
:
'
mp1h
'
,
regions
:
[
mr1lh
,
mr0lh
,
mr0rh
,
mr1rh
]
}
const
mpWrong
=
{
name
:
'
mp1h
'
,
regions
:
[
mr1wrong
,
mr0wrong
]
}
const
mp0
=
{
name
:
'
mp0
'
,
regions
:
[
mr1
,
mr0
]
}
// templates
const
mt0
=
{
name
:
'
mt0
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/aaa-bbb
'
,
parcellations
:
[
mp0
]
}
const
mt1
=
{
name
:
'
mt1
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/bbb-bbb
'
,
parcellations
:
[
mp0
]
}
const
mt2
=
{
name
:
'
mt2
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ccc-bbb
'
,
parcellations
:
[
mp1h
]
}
const
mt3
=
{
name
:
'
mt3
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ddd-bbb
'
,
parcellations
:
[
mp1h
]
}
const
mtWrong
=
{
name
:
'
mtWrong
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ddd-bbb
'
,
parcellations
:
[
mpWrong
]
}
const
mockFetchedTemplates
=
[
mt0
,
mt1
,
mt2
,
mt3
,
mtWrong
]
return
{
mockFetchedTemplates
,
mt2
,
mt0
,
mp0
,
mt1
,
mp1h
,
mr0lh
,
mt3
,
mr0rh
}
const
mt2
=
{
name
:
'
mt2
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ccc-bbb
'
,
parcellations
:
[
mp1h
]
}
}
case
EnumParcRegVersion
.
V2_4
:
{
/**
* regions
*/
const
mr1wrong
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
fff-bbb
'
}
}
}
const
mr0wrong
=
{
labelIndex
:
1
,
name
:
'
mr0
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-fff
'
}
}
}
const
mt3
=
{
name
:
'
mt3
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ddd-bbb
'
,
parcellations
:
[
mp1h
]
}
const
mtWrong
=
{
name
:
'
mtWrong
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ddd-bbb
'
,
parcellations
:
[
mpWrong
]
const
mr1lh
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
status
:
'
left hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
const
mr1rh
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
status
:
'
right hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
const
mr0lh
=
{
labelIndex
:
1
,
name
:
'
mr0
'
,
status
:
'
left hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-bbb
'
}
}
}
const
mr0rh
=
{
labelIndex
:
1
,
name
:
'
mr0
'
,
status
:
'
right hemisphere
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
aaa-bbb
'
}
}
}
const
mr1
=
{
labelIndex
:
1
,
name
:
'
mr1
'
,
fullId
:
{
kg
:
{
kgSchema
:
'
fzj/mock/pr
'
,
kgId
:
'
ccc-bbb
'
}
}
}
// parcellations
const
mp1h
=
{
name
:
'
mp1h
'
,
regions
:
[
mr1lh
,
mr0lh
,
mr0rh
,
mr1rh
]
}
const
mpWrong
=
{
name
:
'
mp1h
'
,
regions
:
[
mr1wrong
,
mr0wrong
]
}
const
mp0
=
{
name
:
'
mp0
'
,
regions
:
[
mr1
,
mr0
]
}
// templates
const
mt0
=
{
name
:
'
mt0
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/aaa-bbb
'
,
parcellations
:
[
mp0
]
}
const
mt1
=
{
name
:
'
mt1
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/bbb-bbb
'
,
parcellations
:
[
mp0
]
}
const
mt2
=
{
name
:
'
mt2
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ccc-bbb
'
,
parcellations
:
[
mp1h
]
}
const
mt3
=
{
name
:
'
mt3
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ddd-bbb
'
,
parcellations
:
[
mp1h
]
}
const
mtWrong
=
{
name
:
'
mtWrong
'
,
fullId
:
'
fzj/mock/rs/v0.0.0/ddd-bbb
'
,
parcellations
:
[
mpWrong
]
}
const
mockFetchedTemplates
=
[
mt0
,
mt1
,
mt2
,
mt3
,
mtWrong
]
return
{
mockFetchedTemplates
,
mt2
,
mt0
,
mp0
,
mt1
,
mp1h
,
mr0lh
,
mt3
,
mr0rh
}
}
default
:
throw
new
Error
(
`version needs to be v1.18 or v2.4`
)
}
}
const
mockFetchedTemplates
=
[
mt0
,
mt1
,
mt2
,
mt3
,
mtWrong
]
describe
(
'
> region.base.ts
'
,
()
=>
{
describe
(
'
> regionInOtherTemplateSelector
'
,
()
=>
{
describe
(
'
> no hemisphere selected, simulates big brain cyto map
'
,
()
=>
{
let
result
:
any
[]
beforeAll
(()
=>
{
result
=
regionInOtherTemplateSelector
.
projector
({
fetchedTemplates
:
mockFetchedTemplates
,
templateSelected
:
mt0
},
{
region
:
mr0
})
})
for
(
const
enumKey
of
Object
.
keys
(
EnumParcRegVersion
))
{
describe
(
`> selector version for
${
enumKey
}
`
,
()
=>
{
it
(
'
> length checks out
'
,
()
=>
{
expect
(
result
.
length
).
toEqual
(
5
)
})
const
{
mockFetchedTemplates
,
mt2
,
mt0
,
mp0
,
mt1
,
mp1h
,
mr0lh
,
mt3
,
mr0rh
}
=
getRegionInOtherTemplateSelectorBundle
(
enumKey
as
EnumParcRegVersion
)
it
(
'
> does not contain itself
'
,
()
=>
{
expect
(
result
).
not
.
toContain
(
jasmine
.
objectContaining
({
template
:
mt0
,
parcellation
:
mp0
,
region
:
mr0
describe
(
'
> no hemisphere selected, simulates big brain cyto map
'
,
()
=>
{
let
result
:
any
[]
beforeAll
(()
=>
{
result
=
regionInOtherTemplateSelector
.
projector
({
fetchedTemplates
:
mockFetchedTemplates
,
templateSelected
:
mt0
},
{
region
:
mr0
})
})
)
})
it
(
'
> no hemisphere result has no hemisphere meta data
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt1
,
parcellation
:
mp0
,
region
:
mr0
it
(
'
> length checks out
'
,
()
=>
{
expect
(
result
.
length
).
toEqual
(
5
)
})
)
})
it
(
'
> hemisphere result has hemisphere metadata # 1
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt2
,
parcellation
:
mp1h
,
region
:
mr0lh
,
hemisphere
:
'
left hemisphere
'
it
(
'
> does not contain itself
'
,
()
=>
{
expect
(
result
).
not
.
toContain
(
jasmine
.
objectContaining
({
template
:
mt0
,
parcellation
:
mp0
,
region
:
mr0
})
)
})
)
})
it
(
'
> hemisphere result has hemisphere metadata # 2
'
,
()
=>
{
expect
(
result
).
to
Contain
(
jasmine
.
objectContaining
({
template
:
m
t3
,
parcellat
ion
:
m
p1h
,
region
:
mr0lh
,
hemisphere
:
'
left hemisphere
'
it
(
'
> no hemisphere result has no hemisphere meta data
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
object
Contain
ing
({
template
:
mt1
,
parcellation
:
m
p0
,
reg
ion
:
m
r0
})
)
})
)
})
it
(
'
> hemisphere result has hemisphere metadata # 3
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0rh
,
hemisphere
:
'
right hemisphere
'
it
(
'
> hemisphere result has hemisphere metadata # 1
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt2
,
parcellation
:
mp1h
,
region
:
mr0lh
,
hemisphere
:
'
left hemisphere
'
})
)
})
)
})
it
(
'
> hemisphere result has hemisphere metadata # 4
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0rh
,
hemisphere
:
'
right hemisphere
'
it
(
'
> hemisphere result has hemisphere metadata # 2
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
(
{
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0lh
,
hemisphere
:
'
left hemisphere
'
})
)
})
)
})
})
describe
(
'
> hemisphere data selected (left hemisphere), simulates julich-brain in mni152
'
,
()
=>
{
let
result
beforeAll
(()
=>
{
result
=
regionInOtherTemplateSelector
.
projector
({
fetchedTemplates
:
mockFetchedTemplates
,
templateSelected
:
mt2
},
{
region
:
mr0lh
})
})
it
(
'
> length checks out
'
,
()
=>
{
expect
(
result
.
length
).
toEqual
(
3
)
})
it
(
'
> does not select wrong hemisphere (right hemisphere)
'
,
()
=>
{
expect
(
result
).
not
.
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0rh
,
it
(
'
> hemisphere result has hemisphere metadata # 3
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0rh
,
hemisphere
:
'
right hemisphere
'
})
)
})
)
})
it
(
'
> select the corresponding hemisphere (left hemisphere), but without hemisphere metadata
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0lh
it
(
'
> hemisphere result has hemisphere metadata # 4
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0rh
,
hemisphere
:
'
right hemisphere
'
})
)
})
)
})
describe
(
'
> hemisphere data selected (left hemisphere), simulates julich-brain in mni152
'
,
()
=>
{
let
result
beforeAll
(()
=>
{
result
=
regionInOtherTemplateSelector
.
projector
({
fetchedTemplates
:
mockFetchedTemplates
,
templateSelected
:
mt2
},
{
region
:
mr0lh
})
})
it
(
'
> length checks out
'
,
()
=>
{
expect
(
result
.
length
).
toEqual
(
3
)
})
it
(
'
> does not select wrong hemisphere (right hemisphere)
'
,
()
=>
{
expect
(
result
).
not
.
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0rh
,
})
)
})
it
(
'
> select the corresponding hemisphere (left hemisphere), but without hemisphere metadata
'
,
()
=>
{
expect
(
result
).
toContain
(
jasmine
.
objectContaining
({
template
:
mt3
,
parcellation
:
mp1h
,
region
:
mr0lh
})
)
})
})
})
}
)
}
})
describe
(
'
> RegionBase
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment