Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.editor
Commits
fddb4d95
Commit
fddb4d95
authored
6 years ago
by
Flavio TARSETTI
Browse files
Options
Downloads
Patches
Plain Diff
[plotterparameter] added unit test in PlotterParameterEditor.spec.jsx
parent
54c38a99
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!32
[plotterparameter] unit tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
conda/js/src/components/plotterparameter/PlotterParameterEditor.spec.jsx
+126
-0
126 additions, 0 deletions
...mponents/plotterparameter/PlotterParameterEditor.spec.jsx
with
126 additions
and
0 deletions
conda/js/src/components/plotterparameter/PlotterParameterEditor.spec.jsx
+
126
−
0
View file @
fddb4d95
// @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
'
:
''
}
});
});
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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