Skip to content

Commit

Permalink
improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed Nov 22, 2024
1 parent 7ac9cf5 commit c9c5d2a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/test-app/tests/integration/components/fade-text-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ module('Integration | Component | fade-text', function (hooks) {
});

test('it fades tall text given as component argument', async function (assert) {
assert.expect(5);
this.set('longHtml', this.longHtml);

this.set('expanded', false);
this.set('onExpandAll', (isExpanded) => {
this.set('expanded', isExpanded);
assert.strictEqual(this.expanded, isExpanded);
});
await render(
hbs`<FadeText @text={{this.longHtml}} @expanded={{this.expanded}} @onExpandAll={{this.onExpandAll}} />`,
Expand All @@ -67,28 +65,29 @@ module('Integration | Component | fade-text', function (hooks) {
// slight delay to allow for proper loading of component
await waitFor(this.fadedSelector);

assert.false(this.expanded);
assert.dom('.display-text-wrapper', this.element).hasClass(this.fadedClass);

await component.expand.click();

assert.true(this.expanded);
assert.dom('.display-text-wrapper', this.element).doesNotHaveClass(this.fadedClass);

await component.collapse.click();

// slight delay to allow for proper loading of component
await waitFor(this.fadedSelector);

assert.false(this.expanded);
assert.dom('.display-text-wrapper', this.element).hasClass(this.fadedClass);
});

test('it fades tall text given as block', async function (assert) {
assert.expect(5);
this.set('longHtml', this.longHtml);

this.set('expanded', false);
this.set('onExpandAll', (isExpanded) => {
this.set('expanded', isExpanded);
assert.strictEqual(this.expanded, isExpanded);
});

await render(hbs`<FadeText
Expand Down Expand Up @@ -116,30 +115,31 @@ module('Integration | Component | fade-text', function (hooks) {
// slight delay to allow for proper loading of component
await waitFor(this.fadedSelector);

assert.false(this.expanded);
assert.dom('.display-text-wrapper', this.element).hasClass(this.fadedClass);

await component.expand.click();

assert.true(this.expanded);
assert.dom('.display-text-wrapper', this.element).doesNotHaveClass(this.fadedClass);

await component.collapse.click();

// slight delay to allow for proper loading of component
await waitFor(this.fadedSelector);

assert.false(this.expanded);
assert.dom('.display-text-wrapper', this.element).hasClass(this.fadedClass);
});

test('expand/collapse', async function (assert) {
assert.expect(12);
const longText = `An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades. An objective description so long that it fades.`;
this.set('longHtml', this.longHtml);
this.set('longText', longText);

this.set('expanded', false);
this.set('onExpandAll', (isExpanded) => {
this.set('expanded', isExpanded);
assert.strictEqual(this.expanded, isExpanded);
});
await render(
hbs`<FadeText @text={{this.longHtml}} @expanded={{this.expanded}} @onExpandAll={{this.onExpandAll}} />`,
Expand All @@ -148,13 +148,15 @@ module('Integration | Component | fade-text', function (hooks) {
// slight delay to allow for proper loading of component
await waitFor(this.fadedSelector);

assert.false(this.expanded);
assert.dom('.display-text-wrapper', this.element).hasClass(this.fadedClass);
assert.strictEqual(component.text, longText, 'component text matches');
assert.ok(component.expand.isVisible, 'expand button is visible');
assert.notOk(component.collapse.isVisible, 'collapse button is NOT visible');

await component.expand.click();

assert.true(this.expanded);
assert.dom('.display-text-wrapper', this.element).doesNotHaveClass(this.fadedClass);
assert.notOk(component.expand.isVisible, 'expand button is NOT visible');
assert.ok(component.collapse.isVisible, 'collpase button is visible');
Expand All @@ -164,6 +166,7 @@ module('Integration | Component | fade-text', function (hooks) {
// slight delay to allow for proper loading of component
await waitFor(this.fadedSelector);

assert.false(this.expanded);
assert.dom('.display-text-wrapper', this.element).hasClass(this.fadedClass);
assert.ok(component.expand.isVisible);
assert.notOk(component.collapse.isVisible);
Expand Down

0 comments on commit c9c5d2a

Please sign in to comment.