mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-04 23:00:25 +00:00
Add tests for dataset health score table
This commit is contained in:
parent
3481848470
commit
8f49e5e7fd
@ -1,26 +1,48 @@
|
|||||||
import { module, test } from 'qunit';
|
import { moduleForComponent, test } from 'ember-qunit';
|
||||||
import { setupRenderingTest } from 'ember-qunit';
|
import { run } from '@ember/runloop';
|
||||||
import { render } from '@ember/test-helpers';
|
|
||||||
import hbs from 'htmlbars-inline-precompile';
|
import hbs from 'htmlbars-inline-precompile';
|
||||||
|
import healthDetail from 'wherehows-web/mirage/fixtures/health-detail';
|
||||||
|
|
||||||
module('Integration | Component | datasets/health/score-table', function(hooks) {
|
moduleForComponent('datasets/health/score-table', 'Integration | Component | datasets/health/score-table', {
|
||||||
setupRenderingTest(hooks);
|
integration: true
|
||||||
|
});
|
||||||
test('it renders', async function(assert) {
|
|
||||||
// Set any properties with this.set('myProperty', 'value');
|
const table = '.dataset-health__score-table';
|
||||||
// Handle any actions with this.set('myAction', function(val) { ... });
|
const row = `${table}__row`;
|
||||||
|
|
||||||
await render(hbs`{{datasets/health/score-table}}`);
|
test('it renders', async function(assert) {
|
||||||
|
this.render(hbs`{{datasets/health/score-table}}`);
|
||||||
assert.equal(this.element.textContent.trim(), '');
|
|
||||||
|
assert.ok(this.$(), 'Renders without errors as standalone component');
|
||||||
// Template block usage:
|
});
|
||||||
await render(hbs`
|
|
||||||
{{#datasets/health/score-table}}
|
test('it renders the correct information', async function(assert) {
|
||||||
template block text
|
const tableData = healthDetail;
|
||||||
{{/datasets/health/score-table}}
|
|
||||||
`);
|
this.set('tableData', tableData);
|
||||||
|
this.render(hbs`{{datasets/health/score-table
|
||||||
assert.equal(this.element.textContent.trim(), 'template block text');
|
tableData=tableData}}`);
|
||||||
});
|
|
||||||
|
assert.ok(this.$(), 'Still renders without errors');
|
||||||
|
assert.equal(this.$(table).length, 1, 'Renders one table');
|
||||||
|
assert.equal(this.$(row).length, tableData.length, 'Renders one row for every detail data');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('it filters correctly', async function(assert) {
|
||||||
|
const tableData = healthDetail;
|
||||||
|
const numComplianceRows = tableData.reduce((sum, curr) => sum + (curr.category === 'Compliance' ? 1 : 0), 0);
|
||||||
|
|
||||||
|
this.setProperties({
|
||||||
|
tableData,
|
||||||
|
categoryFilter: 'Compliance',
|
||||||
|
severityFilter: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
this.render(hbs`{{datasets/health/score-table
|
||||||
|
tableData=tableData
|
||||||
|
currentCategoryFilter=categoryFilter
|
||||||
|
currentSeverityFilter=severityFilter}}`);
|
||||||
|
|
||||||
|
assert.ok(this.$(), 'Still renders further without errors');
|
||||||
|
assert.equal(this.$(row).length, numComplianceRows, 'Show correct rows based on filter');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user