2018-07-30 20:58:27 -07:00
|
|
|
import { moduleForComponent, test } from 'ember-qunit';
|
2018-07-30 16:55:08 -07:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
|
2018-07-30 20:58:27 -07:00
|
|
|
moduleForComponent(
|
|
|
|
'visualization/charts/horizontal-bar-chart',
|
|
|
|
'Integration | Component | visualization/charts/horizontal-bar-chart',
|
|
|
|
{ integration: true }
|
|
|
|
);
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-07-30 20:58:27 -07:00
|
|
|
/* Selectors */
|
|
|
|
const chartTitle = '.viz-bar-chart__title';
|
|
|
|
const chartBar = 'rect';
|
|
|
|
const chartLabel = '.highcharts-data-label';
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-07-30 20:58:27 -07:00
|
|
|
test('it renders', async function(assert) {
|
|
|
|
this.render(hbs`{{visualization/charts/horizontal-bar-chart}}`);
|
|
|
|
assert.ok(this.$(), 'Renders without errors');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it displays the correct graph information', async function(assert) {
|
|
|
|
const title = 'Pokemon Values';
|
|
|
|
const series = [
|
|
|
|
{ name: 'Mewtwo', value: 150 },
|
|
|
|
{ name: 'Alakazam', value: 65 },
|
|
|
|
{ name: 'Pikachu', value: 25 },
|
|
|
|
{ name: 'Charmander', value: 4 }
|
|
|
|
];
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-07-30 20:58:27 -07:00
|
|
|
this.setProperties({ title, series });
|
|
|
|
this.render(hbs`{{visualization/charts/horizontal-bar-chart
|
|
|
|
series=series
|
|
|
|
title=title}}`);
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-07-30 20:58:27 -07:00
|
|
|
assert.ok(this.$(), 'Still renders without errors');
|
|
|
|
assert.equal(this.$(chartBar).length, series.length, 'Renders 3 bars');
|
|
|
|
assert.equal(this.$(chartLabel).length, series.length, 'Renders 3 labels');
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-07-30 20:58:27 -07:00
|
|
|
assert.equal(
|
|
|
|
this.$('text:eq(0)')
|
|
|
|
.text()
|
|
|
|
.trim()
|
|
|
|
.replace(/[ \n]/g, ''),
|
|
|
|
'150|Mewtwo',
|
|
|
|
'Renders the correct first label'
|
|
|
|
);
|
2018-07-30 16:55:08 -07:00
|
|
|
});
|