2018-08-09 10:41:52 -07:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
2018-08-09 23:25:55 -07:00
|
|
|
import { render, findAll, find } from '@ember/test-helpers';
|
2018-07-30 16:55:08 -07:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
module('Integration | Component | visualization/charts/horizontal-bar-chart', function(hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-08-09 10:41:52 -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-08-09 10:41:52 -07:00
|
|
|
test('it renders', async function(assert) {
|
|
|
|
await render(hbs`{{visualization/charts/horizontal-bar-chart}}`);
|
|
|
|
assert.ok(this.$(), 'Renders without errors');
|
|
|
|
});
|
2018-07-30 20:58:27 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
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-08-09 10:41:52 -07:00
|
|
|
this.setProperties({ title, series });
|
|
|
|
await render(hbs`{{visualization/charts/horizontal-bar-chart
|
|
|
|
series=series
|
|
|
|
title=title}}`);
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
assert.ok(this.$(), 'Still renders without errors');
|
2018-08-09 23:25:55 -07:00
|
|
|
assert.equal(findAll(chartBar).length, series.length, 'Renders 3 bars');
|
|
|
|
assert.equal(findAll(chartLabel).length, series.length, 'Renders 3 labels');
|
2018-07-30 16:55:08 -07:00
|
|
|
|
2018-08-09 10:41:52 -07:00
|
|
|
assert.equal(
|
2018-08-09 23:25:55 -07:00
|
|
|
find('text')
|
|
|
|
.textContent.trim()
|
2018-08-09 10:41:52 -07:00
|
|
|
.replace(/[ \n]/g, ''),
|
|
|
|
'150|Mewtwo',
|
|
|
|
'Renders the correct first label'
|
|
|
|
);
|
|
|
|
});
|
2018-07-30 16:55:08 -07:00
|
|
|
});
|