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
9eb2a3f1
Commit
9eb2a3f1
authored
4 years ago
by
Xiao Gui
Browse files
Options
Downloads
Patches
Plain Diff
chore: added unit tests for glue
chore: handling ie syntax error
parent
d112bfc5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/glue.spec.ts
+48
-3
48 additions, 3 deletions
src/glue.spec.ts
src/glue.ts
+0
-9
0 additions, 9 deletions
src/glue.ts
third_party/catchSyntaxError.js
+3
-3
3 additions, 3 deletions
third_party/catchSyntaxError.js
with
51 additions
and
15 deletions
src/glue.spec.ts
+
48
−
3
View file @
9eb2a3f1
...
@@ -5,11 +5,12 @@ import { provideMockStore, MockStore } from "@ngrx/store/testing"
...
@@ -5,11 +5,12 @@ import { provideMockStore, MockStore } from "@ngrx/store/testing"
import
{
getRandomHex
}
from
'
common/util
'
import
{
getRandomHex
}
from
'
common/util
'
import
{
EnumWidgetTypes
,
TypeOpenedWidget
,
uiActionSetPreviewingDatasetFiles
}
from
"
./services/state/uiState.store.helper
"
import
{
EnumWidgetTypes
,
TypeOpenedWidget
,
uiActionSetPreviewingDatasetFiles
}
from
"
./services/state/uiState.store.helper
"
import
{
hot
}
from
"
jasmine-marbles
"
import
{
hot
}
from
"
jasmine-marbles
"
import
*
as
DATABROWSER_MODULE_EXPORTS
from
'
src/ui/databrowserModule
'
import
{
HttpClientTestingModule
,
HttpTestingController
}
from
"
@angular/common/http/testing
"
import
{
HttpClientTestingModule
,
HttpTestingController
}
from
"
@angular/common/http/testing
"
import
{
glueActionToggleDatasetPreview
}
from
'
./glue
'
import
{
glueActionToggleDatasetPreview
}
from
'
./glue
'
import
{
getIdObj
}
from
'
common/util
'
import
{
getIdObj
}
from
'
common/util
'
import
{
DS_PREVIEW_URL
}
from
'
src/util/constants
'
import
{
DS_PREVIEW_URL
}
from
'
src/util/constants
'
import
{
NgLayersService
}
from
"
./ui/layerbrowser/ngLayerService.service
"
import
{
EnumColorMapName
}
from
"
./util/colorMaps
"
const
mockActionOnSpyReturnVal0
=
{
const
mockActionOnSpyReturnVal0
=
{
id
:
getRandomHex
(),
id
:
getRandomHex
(),
...
@@ -32,7 +33,14 @@ let actionOnWidgetSpy
...
@@ -32,7 +33,14 @@ let actionOnWidgetSpy
const
nifti
=
{
const
nifti
=
{
mimetype
:
"
application/nifti
"
,
mimetype
:
"
application/nifti
"
,
url
:
"
http://abc.xyz
"
,
url
:
"
http://abc.xyz
"
,
referenceSpaces
:
[]
referenceSpaces
:
[],
volumeMetadata
:
{
min
:
0.1
,
max
:
0.45
,
colormap
:
'
viridis
'
},
name
:
'
helloworld
'
,
filename
:
'
foobar
'
}
}
const
chart
=
{
const
chart
=
{
...
@@ -88,7 +96,8 @@ describe('> glue.ts', () => {
...
@@ -88,7 +96,8 @@ describe('> glue.ts', () => {
{
{
provide
:
ACTION_TO_WIDGET_TOKEN
,
provide
:
ACTION_TO_WIDGET_TOKEN
,
useValue
:
actionOnWidgetSpy
useValue
:
actionOnWidgetSpy
}
},
NgLayersService
]
]
})
})
})
})
...
@@ -247,6 +256,42 @@ describe('> glue.ts', () => {
...
@@ -247,6 +256,42 @@ describe('> glue.ts', () => {
const
req
=
ctrl
.
expectOne
(
`
${
DS_PREVIEW_URL
}
/
${
datasetId
}
/
${
encodeURIComponent
(
filename
)}
`
)
const
req
=
ctrl
.
expectOne
(
`
${
DS_PREVIEW_URL
}
/
${
datasetId
}
/
${
encodeURIComponent
(
filename
)}
`
)
req
.
flush
(
nifti
)
req
.
flush
(
nifti
)
}))
}))
it
(
'
> on previewing nifti, thresholds, colormap and remove bg flag set properly
'
,
fakeAsync
(()
=>
{
const
store
=
TestBed
.
inject
(
MockStore
)
const
ctrl
=
TestBed
.
inject
(
HttpTestingController
)
const
layerService
=
TestBed
.
inject
(
NgLayersService
)
const
highThresholdMapSpy
=
spyOn
(
layerService
.
highThresholdMap
,
'
set
'
).
and
.
callThrough
()
const
lowThresholdMapSpy
=
spyOn
(
layerService
.
lowThresholdMap
,
'
set
'
).
and
.
callThrough
()
const
colorMapMapSpy
=
spyOn
(
layerService
.
colorMapMap
,
'
set
'
).
and
.
callThrough
()
const
bgFlagSpy
=
spyOn
(
layerService
.
removeBgMap
,
'
set
'
).
and
.
callThrough
()
const
glue
=
TestBed
.
inject
(
DatasetPreviewGlue
)
store
.
setState
({
uiState
:
{
previewingDatasetFiles
:
[
file1
]
}
})
const
{
datasetId
,
filename
}
=
file1
// debounce at 100ms
tick
(
200
)
const
req
=
ctrl
.
expectOne
(
`
${
DS_PREVIEW_URL
}
/
${
datasetId
}
/
${
encodeURIComponent
(
filename
)}
`
)
req
.
flush
(
nifti
)
const
{
name
,
volumeMetadata
}
=
nifti
const
{
min
,
max
}
=
volumeMetadata
expect
(
highThresholdMapSpy
).
toHaveBeenCalledWith
(
name
,
max
)
expect
(
lowThresholdMapSpy
).
toHaveBeenCalledWith
(
name
,
min
)
expect
(
colorMapMapSpy
).
toHaveBeenCalledWith
(
name
,
EnumColorMapName
.
VIRIDIS
)
expect
(
bgFlagSpy
).
toHaveBeenCalledWith
(
name
,
true
)
}))
})
})
describe
(
'
> #actionOnWidget
'
,
()
=>
{
describe
(
'
> #actionOnWidget
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/glue.ts
+
0
−
9
View file @
9eb2a3f1
...
@@ -449,15 +449,6 @@ export const SAVE_USER_DATA = new InjectionToken<TypeSaveUserData>('SAVE_USER_DA
...
@@ -449,15 +449,6 @@ export const SAVE_USER_DATA = new InjectionToken<TypeSaveUserData>('SAVE_USER_DA
type
TypeSaveUserData
=
(
key
:
string
,
value
:
string
)
=>
void
type
TypeSaveUserData
=
(
key
:
string
,
value
:
string
)
=>
void
@
Injectable
({
providedIn
:
'
root
'
})
export
class
DatasetUserGlue
{
}
export
const
gluActionFavDataset
=
createAction
(
export
const
gluActionFavDataset
=
createAction
(
'
[glue] favDataset
'
,
'
[glue] favDataset
'
,
props
<
{
dataentry
:
Partial
<
IKgDataEntry
>
}
>
()
props
<
{
dataentry
:
Partial
<
IKgDataEntry
>
}
>
()
...
...
This diff is collapsed.
Click to expand it.
third_party/catchSyntaxError.js
+
3
−
3
View file @
9eb2a3f1
(
()
=>
{
(
function
()
{
window
.
onerror
=
e
=>
{
window
.
onerror
=
function
(
e
)
{
if
(
/^SyntaxError/
.
test
(
e
))
{
if
(
/^SyntaxError/
.
test
(
e
)
||
/^Syntax
\s
error/
.
test
(
e
)
)
{
console
.
log
(
'
Caught SyntaxError
'
)
console
.
log
(
'
Caught SyntaxError
'
)
const
warning
=
'
Your browser cannot display the interactive viewer. Please use either Chrome >= 56 and/or Firefox >= 51
'
const
warning
=
'
Your browser cannot display the interactive viewer. Please use either Chrome >= 56 and/or Firefox >= 51
'
...
...
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