Skip to content

Commit cb2444d

Browse files
committed
Add test for span gaps
see #381
1 parent 28254dd commit cb2444d

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.chartjs.model;
17+
18+
import org.junit.jupiter.api.Test;
19+
20+
import software.xdev.chartjs.model.charts.LineChart;
21+
import software.xdev.chartjs.model.data.LineData;
22+
import software.xdev.chartjs.model.dataset.LineDataset;
23+
import software.xdev.chartjs.model.options.LineOptions;
24+
25+
26+
@SuppressWarnings("java:S2699") // Done in custom method
27+
class LineChartTest extends AbstractChartTest
28+
{
29+
@Test
30+
void testWithSpanGaps()
31+
{
32+
final LineDataset dataset1 = new LineDataset()
33+
.setLabel("A")
34+
.setData(65, 59, null, 45, 80)
35+
.setBorderColor("blue")
36+
.setBackgroundColor("rgba(0, 0, 255, 0.2)");
37+
38+
final LineDataset dataset2 = new LineDataset()
39+
.setLabel("B")
40+
.setData(28, 45, null, 45, 10)
41+
.setBorderColor("gray");
42+
43+
final LineData data = new LineData()
44+
.addLabels("1", "2", "3", "4", "5")
45+
.addDataset(dataset1)
46+
.addDataset(dataset2);
47+
48+
final LineOptions options = new LineOptions()
49+
.setAnimation(false)
50+
.setSpanGaps(true);
51+
52+
this.createScreenshotAndCompare(
53+
new LineChart(data, options),
54+
this.getWebContainer(),
55+
"SpanGaps"
56+
);
57+
}
58+
}
31.7 KB
Loading

0 commit comments

Comments
 (0)