2018-09-28 21:45:30 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render, fillIn } from '@ember/test-helpers';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Integration | Component | ttl picker', function (hooks) {
|
2018-09-28 21:45:30 +00:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
hooks.beforeEach(function () {
|
2018-09-28 21:45:30 +00:00
|
|
|
this.changeSpy = sinon.spy();
|
|
|
|
this.set('onChange', this.changeSpy);
|
|
|
|
});
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it renders error on non-number input', async function (assert) {
|
2022-10-18 15:46:02 +00:00
|
|
|
await render(hbs`<TtlPicker @onChange={{this.onChange}} />`);
|
2018-09-28 21:45:30 +00:00
|
|
|
|
|
|
|
let callCount = this.changeSpy.callCount;
|
|
|
|
await fillIn('[data-test-ttl-value]', 'foo');
|
2022-10-18 15:46:02 +00:00
|
|
|
assert.strictEqual(this.changeSpy.callCount, callCount, "it didn't call onChange again");
|
2018-09-28 21:45:30 +00:00
|
|
|
assert.dom('[data-test-ttl-error]').includesText('Error', 'renders the error box');
|
|
|
|
await fillIn('[data-test-ttl-value]', '33');
|
2022-03-18 23:47:42 +00:00
|
|
|
assert.dom('[data-test-ttl-error]').doesNotExist('removes the error box');
|
2018-09-28 21:45:30 +00:00
|
|
|
});
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it shows 30s for invalid duration initialValue input', async function (assert) {
|
2022-10-18 15:46:02 +00:00
|
|
|
await render(hbs`<TtlPicker @onChange={{this.onChange}} @initialValue="invalid" />`);
|
2018-09-28 21:45:30 +00:00
|
|
|
assert.dom('[data-test-ttl-value]').hasValue('30', 'sets 30 as the default');
|
|
|
|
});
|
|
|
|
});
|