2018-09-25 16:28:26 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render } from '@ember/test-helpers';
|
2018-05-25 20:33:22 +00:00
|
|
|
import { create } from 'ember-cli-page-object';
|
|
|
|
import uiPanel from 'vault/tests/pages/components/console/ui-panel';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
|
|
|
|
const component = create(uiPanel);
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
module('Integration | Component | console/ui panel', function(hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
2018-05-25 20:33:22 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it renders', async function(assert) {
|
|
|
|
await render(hbs`{{console/ui-panel}}`);
|
|
|
|
assert.ok(component.hasInput);
|
|
|
|
});
|
2018-05-25 20:33:22 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it clears console input on enter', async function(assert) {
|
|
|
|
await render(hbs`{{console/ui-panel}}`);
|
|
|
|
await component.runCommands('list this/thing/here');
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(component.consoleInputValue, '', 'empties input field on enter');
|
|
|
|
});
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it clears the log when using clear command', async function(assert) {
|
|
|
|
await render(hbs`{{console/ui-panel}}`);
|
|
|
|
await component.runCommands(['list this/thing/here', 'list this/other/thing', 'read another/thing']);
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.notEqual(component.logOutput, '', 'there is output in the log');
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
await component.runCommands('clear');
|
|
|
|
await component.up();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(component.logOutput, '', 'clears the output log');
|
|
|
|
assert.equal(
|
|
|
|
component.consoleInputValue,
|
|
|
|
'clear',
|
|
|
|
'populates console input with previous command on up after enter'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it adds command to history on enter', async function(assert) {
|
|
|
|
await render(hbs`{{console/ui-panel}}`);
|
|
|
|
await component.runCommands('list this/thing/here');
|
|
|
|
await component.up();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(
|
|
|
|
component.consoleInputValue,
|
|
|
|
'list this/thing/here',
|
|
|
|
'populates console input with previous command on up after enter'
|
|
|
|
);
|
2018-09-25 16:28:26 +00:00
|
|
|
await component.down();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(component.consoleInputValue, '', 'populates console input with next command on down');
|
|
|
|
});
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it cycles through history with more than one command', async function(assert) {
|
|
|
|
await render(hbs`{{console/ui-panel}}`);
|
|
|
|
await component.runCommands(['list this/thing/here', 'read that/thing/there', 'qwerty']);
|
|
|
|
await component.up();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(
|
|
|
|
component.consoleInputValue,
|
|
|
|
'qwerty',
|
|
|
|
'populates console input with previous command on up after enter'
|
|
|
|
);
|
2018-09-25 16:28:26 +00:00
|
|
|
await component.up();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(
|
|
|
|
component.consoleInputValue,
|
|
|
|
'read that/thing/there',
|
|
|
|
'populates console input with previous command on up'
|
|
|
|
);
|
2018-09-25 16:28:26 +00:00
|
|
|
await component.up();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(
|
|
|
|
component.consoleInputValue,
|
|
|
|
'list this/thing/here',
|
|
|
|
'populates console input with previous command on up'
|
|
|
|
);
|
2018-09-25 16:28:26 +00:00
|
|
|
await component.up();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(
|
|
|
|
component.consoleInputValue,
|
|
|
|
'qwerty',
|
|
|
|
'populates console input with initial command if cycled through all previous commands'
|
|
|
|
);
|
2018-09-25 16:28:26 +00:00
|
|
|
await component.down();
|
2018-05-25 20:33:22 +00:00
|
|
|
assert.equal(
|
|
|
|
component.consoleInputValue,
|
|
|
|
'',
|
|
|
|
'clears console input if down pressed after history is on most recent command'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|