Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase test coverage #172

Merged
merged 3 commits into from
Jan 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tests/integration/modifiers/autoresize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import hbs from 'htmlbars-inline-precompile';
module('Integration | Modifier | autoresize', function (hooks) {
setupRenderingTest(hooks);

let shortString = 'abc';
let longString;
hooks.beforeEach(function () {
longString = '';
Expand Down Expand Up @@ -42,6 +43,50 @@ module('Integration | Modifier | autoresize', function (hooks) {
assert.extendedDom('textarea').doesNotOverflowY();
});

test('it resizes textarea height to fit input min height on initial render with small value', async function (assert) {
this.set('value', shortString);

await render(
hbs`<textarea style="padding: 0; min-height: 50px;" value={{this.value}} {{autoresize}} />`
);
let textarea = find('textarea');
assert.strictEqual(textarea.scrollHeight, 50);
assert.extendedDom('textarea').doesNotOverflowY();
});

test('it resizes textarea height to fit input min height on initial render with long value', async function (assert) {
this.set('value', longString);

await render(
hbs`<textarea style="min-height: 50px;" value={{this.value}} {{autoresize}} />`
);
let textarea = find('textarea');
assert.ok(textarea.scrollHeight > 50);
assert.extendedDom('textarea').doesNotOverflowY();
});

test('it resizes textarea width to fit input min width on initial render', async function (assert) {
this.set('value', shortString);

await render(
hbs`<textarea style="padding: 0; min-width: 200px;" value={{this.value}} {{autoresize mode="width"}} />`
);
let textarea = find('textarea');
assert.strictEqual(textarea.scrollWidth, 200);
assert.extendedDom('textarea').doesNotOverflowX();
});

test('it resizes textarea width to fit input min width on initial render with long value', async function (assert) {
this.set('value', longString);

await render(
hbs`<textarea style="min-width: 50px;" value={{this.value}} {{autoresize mode="width"}} />`
);
let textarea = find('textarea');
assert.ok(textarea.scrollWidth > 50);
assert.extendedDom('textarea').doesNotOverflowX();
});

test('it grows textarea height on input to fit value', async function (assert) {
await render(hbs`<textarea {{autoresize}} />`);

Expand Down