Skip to content

Commit 0132e40

Browse files
authored
test: remove Polymer fixture from charts tests, extract styles (#9136)
1 parent 7b91f8a commit 0132e40

File tree

4 files changed

+50
-60
lines changed

4 files changed

+50
-60
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2+
3+
registerStyles(
4+
'vaadin-chart',
5+
css`
6+
/* Ensure exporting works with complex selectors */
7+
.highcharts-color-0 {
8+
stroke: red;
9+
fill: red;
10+
}
11+
12+
:host(#chart) .highcharts-color-0 {
13+
stroke: blue;
14+
fill: blue;
15+
}
16+
17+
:host(.my-class .dummy-class) .highcharts-color-0 {
18+
stroke: blue;
19+
fill: blue;
20+
}
21+
22+
:host(.ColumnLineAndPie) g.highcharts-markers > .highcharts-point {
23+
fill: white;
24+
}
25+
26+
:host(.GaugeWithDualAxes) .kmh .highcharts-tick,
27+
:host(.GaugeWithDualAxes) .kmh .highcharts-axis-line {
28+
stroke: #339;
29+
stroke-width: 2;
30+
}
31+
`,
32+
);

packages/charts/test/exporting.test.js

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,13 @@ import { expect } from '@vaadin/chai-plugins';
22
import { fixtureSync, nextRender, oneEvent } from '@vaadin/testing-helpers';
33
import sinon from 'sinon';
44
import '../theme/vaadin-chart-base-theme.js';
5+
import './exporting-styles.js';
56
import '../src/vaadin-chart.js';
6-
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
77
import HttpUtilities from 'highcharts/es-modules/Core/HttpUtilities.js';
88
import Highcharts from 'highcharts/es-modules/masters/highstock.src.js';
9-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10-
import { chartBaseTheme } from '../theme/vaadin-chart-base-theme.js';
11-
12-
const chart = css`
13-
/* Ensure exporting works with complex selectors */
14-
.highcharts-color-0 {
15-
stroke: red;
16-
fill: red;
17-
}
18-
19-
:host(#chart) .highcharts-color-0 {
20-
stroke: blue;
21-
fill: blue;
22-
}
23-
24-
:host(.my-class .dummy-class) .highcharts-color-0 {
25-
stroke: blue;
26-
fill: blue;
27-
}
28-
29-
:host(.ColumnLineAndPie) g.highcharts-markers > .highcharts-point {
30-
fill: white;
31-
}
32-
33-
:host(.GaugeWithDualAxes) .kmh .highcharts-tick,
34-
:host(.GaugeWithDualAxes) .kmh .highcharts-axis-line {
35-
stroke: #339;
36-
stroke-width: 2;
37-
}
38-
`;
39-
40-
registerStyles('vaadin-chart', [chartBaseTheme, chart]);
41-
42-
customElements.define(
43-
'chart-exporting',
44-
class extends PolymerElement {
45-
static get template() {
46-
return html`
47-
<vaadin-chart id="chart" class="my-class dummy-class">
48-
<vaadin-chart-series values="[19,12,9,24,5]"></vaadin-chart-series>
49-
</vaadin-chart>
50-
`;
51-
}
52-
},
53-
);
549

5510
describe('vaadin-chart exporting', () => {
56-
let wrapper, chart, chartContainer, fireEventSpy;
11+
let chart, chartContainer, fireEventSpy;
5712

5813
before(() => {
5914
// Prevent form submit
@@ -63,8 +18,11 @@ describe('vaadin-chart exporting', () => {
6318
});
6419

6520
beforeEach(async () => {
66-
wrapper = fixtureSync('<chart-exporting></chart-exporting>');
67-
chart = wrapper.$.chart;
21+
chart = fixtureSync(`
22+
<vaadin-chart id="chart" class="my-class dummy-class">
23+
<vaadin-chart-series values="[19,12,9,24,5]"></vaadin-chart-series>
24+
</vaadin-chart>
25+
`);
6826
chart.additionalOptions = { exporting: { enabled: true } };
6927
await oneEvent(chart, 'chart-add-series');
7028
chartContainer = chart.$.chart;

packages/charts/test/styling.test.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
import { expect } from '@vaadin/chai-plugins';
22
import { fixtureSync, oneEvent } from '@vaadin/testing-helpers';
33
import '../theme/vaadin-chart-base-theme.js';
4+
import './theme-styles.js';
45
import '../src/vaadin-chart.js';
5-
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
6-
import { chartBaseTheme } from '../theme/vaadin-chart-base-theme.js';
7-
8-
registerStyles('vaadin-chart', [
9-
chartBaseTheme,
10-
css`
11-
:host([theme='custom']) .highcharts-column-series rect.highcharts-point {
12-
stroke: rgb(255, 0, 0);
13-
}
14-
`,
15-
]);
166

177
describe('vaadin-chart styling', () => {
188
describe('default theme', () => {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2+
3+
registerStyles(
4+
'vaadin-chart',
5+
css`
6+
:host([theme='custom']) .highcharts-column-series rect.highcharts-point {
7+
stroke: rgb(255, 0, 0);
8+
}
9+
`,
10+
);

0 commit comments

Comments
 (0)