Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
waterdataui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Water Mission Area
Internet of Water
waterdataui
Commits
bb123470
Commit
bb123470
authored
7 years ago
by
Yan, Andrew N.
Browse files
Options
Downloads
Patches
Plain Diff
add tests for disabling the compare checkbox
parent
6e249954
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
assets/src/scripts/components/hydrograph/index.js
+1
-1
1 addition, 1 deletion
assets/src/scripts/components/hydrograph/index.js
assets/src/scripts/components/hydrograph/index.spec.js
+70
-9
70 additions, 9 deletions
assets/src/scripts/components/hydrograph/index.spec.js
with
71 additions
and
10 deletions
assets/src/scripts/components/hydrograph/index.js
+
1
−
1
View file @
bb123470
...
@@ -284,7 +284,7 @@ const controlLastYearSelect = function(elem, {variable, availableTimeseries}) {
...
@@ -284,7 +284,7 @@ const controlLastYearSelect = function(elem, {variable, availableTimeseries}) {
.
property
(
'
checked
'
,
false
)
.
property
(
'
checked
'
,
false
)
.
dispatch
(
'
change
'
);
// trigger a change event
.
dispatch
(
'
change
'
);
// trigger a change event
}
else
{
}
else
{
checkbox
.
property
(
'
disabled
'
,
false
);
checkbox
.
property
(
'
disabled
'
,
null
);
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
assets/src/scripts/components/hydrograph/index.spec.js
+
70
−
9
View file @
bb123470
const
{
select
,
selectAll
}
=
require
(
'
d3-selection
'
);
const
{
select
,
selectAll
}
=
require
(
'
d3-selection
'
);
const
{
provide
}
=
require
(
'
../../lib/redux
'
);
const
{
provide
,
dispatch
}
=
require
(
'
../../lib/redux
'
);
const
{
attachToNode
,
timeSeriesGraph
,
timeSeriesLegend
}
=
require
(
'
./index
'
);
const
{
attachToNode
,
timeSeriesGraph
,
timeSeriesLegend
}
=
require
(
'
./index
'
);
const
{
Actions
,
configureStore
}
=
require
(
'
../../store
'
);
const
{
Actions
,
configureStore
}
=
require
(
'
../../store
'
);
...
@@ -8,6 +8,18 @@ const { Actions, configureStore } = require('../../store');
...
@@ -8,6 +8,18 @@ const { Actions, configureStore } = require('../../store');
const
TEST_STATE
=
{
const
TEST_STATE
=
{
series
:
{
series
:
{
timeSeries
:
{
timeSeries
:
{
'
00010:current
'
:
{
startTime
:
new
Date
(
'
2018-01-02T15:00:00.000-06:00
'
),
endTime
:
new
Date
(
'
2018-01-02T15:00:00.000-06:00
'
),
points
:
[{
dateTime
:
new
Date
(
'
2018-01-02T15:00:00.000-06:00
'
),
value
:
4
,
qualifiers
:
[
'
P
'
]
}],
method
:
'
method1
'
,
tsKey
:
'
current
'
,
variable
:
'
45807190
'
},
'
00060:current
'
:
{
'
00060:current
'
:
{
startTime
:
new
Date
(
'
2018-01-02T15:00:00.000-06:00
'
),
startTime
:
new
Date
(
'
2018-01-02T15:00:00.000-06:00
'
),
endTime
:
new
Date
(
'
2018-01-02T15:00:00.000-06:00
'
),
endTime
:
new
Date
(
'
2018-01-02T15:00:00.000-06:00
'
),
...
@@ -60,6 +72,10 @@ const TEST_STATE = {
...
@@ -60,6 +72,10 @@ const TEST_STATE = {
'
coll3
'
:
{
'
coll3
'
:
{
variable
:
'
45807197
'
,
variable
:
'
45807197
'
,
timeSeries
:
[
'
00060:median
'
]
timeSeries
:
[
'
00060:median
'
]
},
'
coll4
'
:
{
variable
:
'
45807190
'
,
timeSeries
:
[
'
00010:current
'
]
}
}
},
},
requests
:
{
requests
:
{
...
@@ -67,7 +83,7 @@ const TEST_STATE = {
...
@@ -67,7 +83,7 @@ const TEST_STATE = {
timeSeriesCollections
:
[
'
coll1
'
]
timeSeriesCollections
:
[
'
coll1
'
]
},
},
compare
:
{
compare
:
{
timeSeriesCollections
:
[
'
coll2
'
]
timeSeriesCollections
:
[
'
coll2
'
,
'
col4
'
]
},
},
median
:
{
median
:
{
timeSeriesCollections
:
[
'
coll3
'
]
timeSeriesCollections
:
[
'
coll3
'
]
...
@@ -75,11 +91,22 @@ const TEST_STATE = {
...
@@ -75,11 +91,22 @@ const TEST_STATE = {
},
},
variables
:
{
variables
:
{
'
45807197
'
:
{
'
45807197
'
:
{
variableCode
:
'
00060
'
,
variableCode
:
{
value
:
'
00060
'
},
oid
:
'
45807197
'
,
oid
:
'
45807197
'
,
unit
:
{
unit
:
{
unitCode
:
'
unitCode
'
unitCode
:
'
unitCode
'
}
}
},
'
45807190
'
:
{
variableCode
:
{
value
:
'
00010
'
},
oid
:
'
45807190
'
,
unit
:
{
unitCode
:
'
unitCode
'
}
}
}
},
},
methods
:
{
methods
:
{
...
@@ -102,13 +129,21 @@ describe('Hydrograph charting module', () => {
...
@@ -102,13 +129,21 @@ describe('Hydrograph charting module', () => {
let
graphNode
;
let
graphNode
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
select
(
'
body
'
)
let
body
=
select
(
'
body
'
)
;
.
append
(
'
div
'
)
let
hydrograph
=
body
.
append
(
'
div
'
)
.
attr
(
'
id
'
,
'
hydrograph
'
);
.
attr
(
'
id
'
,
'
hydrograph
'
);
hydrograph
.
append
(
'
div
'
)
.
attr
(
'
class
'
,
'
compare-container
'
)
.
append
(
'
input
'
)
.
attr
(
'
type
'
,
'
checkbox
'
)
.
attr
(
'
class
'
,
'
hydrograph-last-year-input
'
);
hydrograph
.
append
(
'
div
'
)
.
attr
(
'
class
'
,
'
hydrograph-container
'
);
graphNode
=
document
.
getElementById
(
'
hydrograph
'
);
graphNode
=
document
.
getElementById
(
'
hydrograph
'
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
select
(
'
.compare-input
'
).
remove
();
select
(
'
#hydrograph
'
).
remove
();
select
(
'
#hydrograph
'
).
remove
();
});
});
...
@@ -123,7 +158,7 @@ describe('Hydrograph charting module', () => {
...
@@ -123,7 +158,7 @@ describe('Hydrograph charting module', () => {
.
call
(
provide
(
store
))
.
call
(
provide
(
store
))
.
call
(
timeSeriesGraph
);
.
call
(
timeSeriesGraph
);
let
svgNodes
=
graphNode
.
getElementsByTagName
(
'
svg
'
);
let
svgNodes
=
graphNode
.
getElementsByTagName
(
'
svg
'
);
expect
(
svgNodes
.
length
).
toBe
(
2
);
expect
(
svgNodes
.
length
).
toBe
(
3
);
expect
(
svgNodes
[
0
].
getAttribute
(
'
viewBox
'
)).
toContain
(
'
400 200
'
);
expect
(
svgNodes
[
0
].
getAttribute
(
'
viewBox
'
)).
toContain
(
'
400 200
'
);
expect
(
graphNode
.
innerHTML
).
toContain
(
'
hydrograph-container
'
);
expect
(
graphNode
.
innerHTML
).
toContain
(
'
hydrograph-container
'
);
});
});
...
@@ -203,8 +238,9 @@ describe('Hydrograph charting module', () => {
...
@@ -203,8 +238,9 @@ describe('Hydrograph charting module', () => {
.
call
(
timeSeriesGraph
);
.
call
(
timeSeriesGraph
);
});
});
it
(
'
should render an svg node
'
,
()
=>
{
it
(
'
should render the correct number svg nodes
'
,
()
=>
{
expect
(
selectAll
(
'
svg
'
).
size
()).
toBe
(
2
);
// one main hydrograph and two sparklines
expect
(
selectAll
(
'
svg
'
).
size
()).
toBe
(
3
);
});
});
it
(
'
should have a defs node
'
,
()
=>
{
it
(
'
should have a defs node
'
,
()
=>
{
...
@@ -234,7 +270,8 @@ describe('Hydrograph charting module', () => {
...
@@ -234,7 +270,8 @@ describe('Hydrograph charting module', () => {
});
});
it
(
'
should have tooltips for the select series table
'
,
()
=>
{
it
(
'
should have tooltips for the select series table
'
,
()
=>
{
expect
(
selectAll
(
'
table .tooltip-table
'
).
size
()).
toBe
(
1
);
// one for each of the two parameters
expect
(
selectAll
(
'
table .tooltip-table
'
).
size
()).
toBe
(
2
);
});
});
it
(
'
should not have tooltips for the select series table when the screen is large
'
,
()
=>
{
it
(
'
should not have tooltips for the select series table when the screen is large
'
,
()
=>
{
...
@@ -289,4 +326,28 @@ describe('Hydrograph charting module', () => {
...
@@ -289,4 +326,28 @@ describe('Hydrograph charting module', () => {
expect
(
selectAll
(
'
g.legend-marker
'
).
size
()).
toBe
(
1
);
expect
(
selectAll
(
'
g.legend-marker
'
).
size
()).
toBe
(
1
);
});
});
});
});
describe
(
'
last year checkbox
'
,
()
=>
{
let
store
;
beforeEach
(()
=>
{
store
=
configureStore
(
TEST_STATE
);
select
(
graphNode
)
.
call
(
provide
(
store
))
.
call
(
timeSeriesGraph
)
.
select
(
'
.hydrograph-last-year-input
'
)
.
on
(
'
change
'
,
dispatch
(
function
()
{
return
Actions
.
toggleTimeseries
(
'
compare
'
,
this
.
checked
);
}));
});
it
(
'
should be enabled if there are last year data
'
,
()
=>
{
expect
(
select
(
'
.hydrograph-last-year-input
'
).
property
(
'
disabled
'
)).
toBeFalsy
();
});
it
(
'
should be disabled if there are no last year data
'
,
()
=>
{
store
.
dispatch
(
Actions
.
setCurrentParameterCode
(
'
00010
'
,
'
45807190
'
));
expect
(
select
(
'
.hydrograph-last-year-input
'
).
property
(
'
disabled
'
)).
toBeTruthy
();
});
});
});
});
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