Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
62e468e9
Commit
62e468e9
authored
Nov 27, 2018
by
Flavio TARSETTI
Browse files
Merge branch 'dev' into 'master'
[plotterparameter] unit tests See merge request
!32
parents
54c38a99
5baa1bc5
Pipeline
#25067
passed with stages
in 30 minutes and 54 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
conda/js/src/components/plotterparameter/PlotterParameterEditor.spec.jsx
View file @
62e468e9
// @flow
import
React
from
'
react
'
;
import
{
expect
}
from
'
chai
'
;
import
{
mount
}
from
'
enzyme
'
;
import
sinon
from
'
sinon
'
;
import
{
spies
}
from
'
@test
'
;
import
{
PlotterParameterEditor
as
C
}
from
'
.
'
;
import
{
getValidPlotterparameterObj
as
getValidObj
}
from
'
@helpers/beat
'
;
import
testPlotterParameters
from
'
@test/test_plotterparameters.json
'
;
import
testPlotters
from
'
@test/test_plotters.json
'
;
const
libs
=
[];
describe
.
only
(
'
<PlotterParameterEditor />
'
,
()
=>
{
let
wrapper
;
afterEach
(()
=>
{
if
(
wrapper
&&
wrapper
.
unmount
)
wrapper
.
unmount
();
});
describe
(
'
accepts
'
,
()
=>
{
const
plotparams
=
[
{
name
:
'
test/myplotterparameter/1
'
,
contents
:
{
description
:
'
A basic plotterparameter as a sanity test for the PlotterParameterEditor
'
,
data
:
{
legend_loc
:
'
string
'
},
plotter
:
"
plot/bar/1
"
}
}
].
concat
(
testPlotterParameters
.
map
(
a
=>
getValidObj
(
a
)));
plotparams
.
forEach
(
function
(
plotparam
){
const
saveFunc
=
()
=>
{};
const
updateFunc
=
()
=>
{};
const
plotters
=
testPlotters
.
filter
(
d
=>
d
.
name
.
startsWith
(
'
plot
'
)).
map
(
testPlotters
=>
testPlotters
.
name
);
it
(
`
${
plotparam
.
name
}
`
,
()
=>
{
wrapper
=
mount
(
<
C
data
=
{
getValidObj
(
plotparam
)
}
plotterparameters
=
{
plotparams
}
plotters
=
{
plotters
}
plotterNames
=
{
plotters
}
saveFunc
=
{
saveFunc
}
updateFunc
=
{
updateFunc
}
/>
);
expect
(
wrapper
).
to
.
have
.
props
(
[
'
data
'
,
'
plotterparameters
'
,
'
plotters
'
,
'
saveFunc
'
,
'
updateFunc
'
]
)
});
});
});
describe
(
'
creates
'
,
()
=>
{
it
(
'
test/createplotparam/1
'
,
()
=>
{
const
saveFunc
=
sinon
.
spy
();
const
_updateFunc
=
(
obj
)
=>
{
wrapper
.
setProps
&&
wrapper
.
setProps
({
data
:
obj
});
};
const
updateFunc
=
sinon
.
spy
(
_updateFunc
);
const
plotparamName
=
'
test/createplotparam/1
'
;
const
plotters
=
testPlotters
.
filter
(
d
=>
d
.
name
.
startsWith
(
'
plot
'
)).
map
(
testPlotters
=>
testPlotters
);
wrapper
=
mount
(
<
C
data
=
{
getValidObj
({
name
:
plotparamName
,
contents
:
{}})
}
plotterparameters
=
{
[]
}
plotters
=
{
plotters
}
plotterNames
=
{
plotters
}
saveFunc
=
{
saveFunc
}
updateFunc
=
{
updateFunc
}
/>
);
expect
(
wrapper
).
to
.
have
.
props
(
[
'
data
'
,
'
plotterparameters
'
,
'
plotters
'
,
'
saveFunc
'
,
'
updateFunc
'
]
);
expect
(
wrapper
.
props
().
data
).
to
.
have
.
property
(
'
name
'
,
plotparamName
);
expect
(
wrapper
.
props
().
data
.
contents
).
to
.
have
.
property
(
'
description
'
);
expect
(
wrapper
.
props
().
data
.
contents
).
to
.
have
.
property
(
'
description
'
).
with
.
lengthOf
(
0
);
wrapper
.
find
(
'
#ppPl select
'
).
simulate
(
'
change
'
,
{
target
:
{
value
:
'
user/anotherploter/1
'
}});
expect
(
updateFunc
.
callCount
).
to
.
equal
(
0
);
wrapper
.
find
(
'
#ppPl select
'
).
simulate
(
'
change
'
,
{
target
:
{
value
:
'
plot/bar/1
'
}});
expect
(
updateFunc
.
callCount
).
to
.
equal
(
1
);
expect
(
wrapper
.
props
().
data
.
contents
).
to
.
have
.
property
(
'
plotter
'
,
'
plot/bar/1
'
);
expect
(
wrapper
.
props
().
data
.
contents
).
to
.
have
.
property
(
'
description
'
).
with
.
lengthOf
(
0
);
expect
(
wrapper
.
props
().
data
.
contents
).
to
.
have
.
property
(
'
plotter
'
).
with
.
lengthOf
(
10
);
expect
(
wrapper
.
props
().
data
.
contents
).
to
.
have
.
property
(
'
data
'
);
expect
(
wrapper
.
props
().
data
.
contents
).
to
.
deep
.
equal
({
'
description
'
:
''
,
'
plotter
'
:
'
plot/bar/1
'
,
'
data
'
:
{
'
axis-fontsize
'
:
10
,
'
bar-alpha
'
:
0.75
,
'
bar-norm
'
:
true
,
'
bar_attributes
'
:
''
,
'
content_type
'
:
'
image/png
'
,
'
dpi
'
:
60
,
'
grid
'
:
false
,
'
height
'
:
300
,
'
legend
'
:
''
,
'
legend-bbox-to-anchor
'
:
1
,
'
legend-fontsize
'
:
12
,
'
legend-loc
'
:
'
best
'
,
'
title
'
:
'
Bar plot
'
,
'
title-fontsize
'
:
10
,
'
width
'
:
400
,
'
xaxis_multiplier
'
:
1
,
'
xlabel
'
:
''
,
'
yaxis_log
'
:
false
,
'
yaxis_multiplier
'
:
1
,
'
ylabel
'
:
''
}
});
});
});
});
conda/js/test/test_plotterparameters.json
0 → 100644
View file @
62e468e9
[
{
"name"
:
"plot/bar/1"
,
"contents"
:
{
"description"
:
"Default parameters for bar plots"
,
"plotter"
:
"plot/bar/1"
,
"data"
:
{
"title-fontsize"
:
12
,
"bar-norm"
:
true
,
"axis-fontsize"
:
10
,
"height"
:
600
,
"width"
:
800
,
"grid"
:
true
,
"bar-alpha"
:
0.75
,
"legend-fontsize"
:
8
,
"legend-loc"
:
"best"
,
"dpi"
:
120
}
}
},
{
"name"
:
"plot/isoroc/1"
,
"contents"
:
{
"description"
:
"Default parameters for an ISO/ROC curve"
,
"plotter"
:
"plot/isoroc/1"
,
"data"
:
{
"ylim-bottom"
:
0
,
"title-fontsize"
:
12
,
"axis-fontsize"
:
10
,
"height"
:
600
,
"width"
:
800
,
"grid"
:
true
,
"ylim-top"
:
100
,
"xlim-right"
:
100
,
"legend-fontsize"
:
8
,
"legend-loc"
:
"best"
,
"xlim-left"
:
0
,
"dpi"
:
120
}
}
}
]
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment