Files
nomad/ui/tests/integration/components/lifecycle-chart-test.js
Buck Doyle 0db4324275 Update template linting and fix missed curly invocations (#8382)
This includes fixes for newer template lint rules that came along with
updating that dependency, which was necessary to be able to use
the no-curly-component-invocation rule. It also updates some curly
invocations that I missed in #8075.
2020-07-09 12:30:11 -05:00

102 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, settled } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { create } from 'ember-cli-page-object';
import LifecycleChart from 'nomad-ui/tests/pages/components/lifecycle-chart';
const Chart = create(LifecycleChart);
const tasks = [
{
lifecycleName: 'main',
name: 'main two',
},
{
lifecycleName: 'main',
name: 'main one',
},
{
lifecycleName: 'prestart',
name: 'prestart',
},
{
lifecycleName: 'sidecar',
name: 'sidecar',
},
];
module('Integration | Component | lifecycle-chart', function(hooks) {
setupRenderingTest(hooks);
test('it renders stateless phases and lifecycle- and name-sorted tasks', async function(assert) {
this.set('tasks', tasks);
await render(hbs`<LifecycleChart @tasks={{tasks}} />`);
assert.ok(Chart.isPresent);
assert.equal(Chart.phases[0].name, 'Prestart');
assert.equal(Chart.phases[1].name, 'Main');
Chart.phases.forEach(phase => assert.notOk(phase.isActive));
assert.deepEqual(Chart.tasks.mapBy('name'), ['prestart', 'sidecar', 'main one', 'main two']);
assert.deepEqual(Chart.tasks.mapBy('lifecycle'), [
'Prestart Task',
'Sidecar Task',
'Main Task',
'Main Task',
]);
assert.ok(Chart.tasks[0].isPrestart);
assert.ok(Chart.tasks[1].isSidecar);
assert.ok(Chart.tasks[2].isMain);
Chart.tasks.forEach(task => {
assert.notOk(task.isActive);
assert.notOk(task.isFinished);
});
});
test('it doesnt render when theres only one phase', async function(assert) {
this.set('tasks', [
{
lifecycleName: 'main',
},
]);
await render(hbs`<LifecycleChart @tasks={{tasks}} />`);
assert.notOk(Chart.isPresent);
});
test('it reflects phase and task states when states are passed in', async function(assert) {
this.set(
'taskStates',
tasks.map(task => {
return { task };
})
);
await render(hbs`<LifecycleChart @taskStates={{taskStates}} />`);
assert.ok(Chart.isPresent);
Chart.phases.forEach(phase => assert.notOk(phase.isActive));
Chart.tasks.forEach(task => {
assert.notOk(task.isActive);
assert.notOk(task.isFinished);
});
this.set('taskStates.firstObject.state', 'running');
await settled();
assert.ok(Chart.phases[1].isActive);
assert.ok(Chart.tasks[3].isActive);
this.set('taskStates.firstObject.finishedAt', new Date());
await settled();
assert.ok(Chart.tasks[3].isFinished);
});
});