46 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-08-01 16:34:55 -07:00
import { moduleForComponent, test } from 'ember-qunit';
import { run } from '@ember/runloop';
import hbs from 'htmlbars-inline-precompile';
2018-08-01 16:34:55 -07:00
moduleForComponent('datasets/health/metrics-charts', 'Integration | Component | datasets/health/metrics-charts', {
integration: true
});
2018-08-01 16:34:55 -07:00
const chartClass = '.viz-bar-chart';
const labelClass = '.highcharts-label';
const labelValueClass = `${labelClass} .highcharts-emphasized`;
const barClass = `${chartClass}__bar`;
2018-08-01 16:34:55 -07:00
test('it renders', async function(assert) {
this.render(hbs`{{datasets/health/metrics-charts}}`);
assert.ok(this.$(), 'Renders without errors');
});
2018-08-01 16:34:55 -07:00
test('it provides the correct information', async function(assert) {
const categoryData = [{ name: 'Compliance', value: 60 }, { name: 'Ownership', value: 40 }];
const severityData = [
{ name: 'Minor', value: 50, customColorClass: 'severity-chart__bar--minor' },
{ name: 'Warning', value: 30, customColorClass: 'severity-chart__bar--warning' },
{ name: 'Critical', value: 25, customColorClass: 'severity-chart__bar--critical' }
];
2018-08-01 16:34:55 -07:00
this.setProperties({
categoryData,
severityData
});
2018-08-01 16:34:55 -07:00
this.render(hbs`{{datasets/health/metrics-charts
categoryData=categoryData
severityData=severityData}}`);
2018-08-01 16:34:55 -07:00
assert.ok(this.$(), 'Still renders without errors');
assert.equal(this.$(chartClass).length, 2, 'Renders 2 charts');
assert.equal(
this.$(`${labelValueClass}:eq(0)`)
.text()
.trim(),
'60%',
'Renders correct value for labels'
);
});