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

Adds test for landing page for new users #97

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
124 changes: 124 additions & 0 deletions tests/integration/components/sign-up/button-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { module, skip } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | sign-up/button', function (hooks) {
setupRenderingTest(hooks);

skip('Button should not render if its content is not present', async function (assert) {
assert.expect(1);

await render(hbs`
<SignUp::Button></SignUp::Button>
`);

assert.dom('[data-test-signup-button]').doesNotExist();
});

skip('Button should be disabled if @disabled is true', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');

await render(hbs`
<SignUp::Button @disabled={{true}}>{{inputValue}}</SignUp::Button>
`);

assert.dom('[data-test-signup-button]').isDisabled();
});

skip('Button should not be disabled if @disabled is undefined', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');

await render(hbs`
<SignUp::Button>{{inputValue}}</SignUp::Button>
`);

assert.dom('[data-test-signup-button]').isNotDisabled();
});

skip('Button should not be disabled if @disabled is not true', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');

await render(hbs`
<SignUp::Button @disabled="hello">{{inputValue}}</SignUp::Button>
`);

assert.dom('[data-test-signup-button]').isNotDisabled();
});

skip('Button should be of type button', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');

await render(hbs`
<SignUp::Button>{{inputValue}}</SignUp::Button>
`);

assert.dom('[data-test-signup-button]').hasAttribute('type', 'button');
});

skip('Button should have spinner if @isSubmitClick is true', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');

await render(hbs`
<SignUp::Button>{{inputValue}}</SignUp::Button>
`);

assert.dom('[data-test-signup-button-spinner]').exists();
});

skip('Button should not have spinner if @isSubmitClick is not true', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');

await render(hbs`
<SignUp::Button>{{inputValue}}</SignUp::Button>
`);

assert.dom('[data-test-signup-button-spinner]').doesNotExist();
});

skip('Click event should not execute if button is disabled', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');
this.set('clickFnc', () => {
this.set('isClicked', true);
});

await render(hbs`
<SignUp::Button @disabled={{true}}>{{inputValue}}</SignUp::Button>
`);

const button = this.element.querySelector(
'[data-test-signup-button-spinner]'
);
button.addEventListener('click', this.clickFn);

await click(button);
assert.notStrictEqual(this.isClicked, true);
});

skip('Click event should execute if button is not disabled', async function (assert) {
assert.expect(1);
this.set('inputValue', 'Get Started');
this.set('clickFnc', () => {
this.set('isClicked', true);
});

await render(hbs`
<SignUp::Button>{{inputValue}}</SignUp::Button>
`);

const button = this.element.querySelector(
'[data-test-signup-button-spinner]'
);
button.addEventListener('click', this.clickFn);

await click(button);
assert.strictEqual(this.isClicked, true);
});
});
42 changes: 42 additions & 0 deletions tests/integration/components/sign-up/form-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { module, skip } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | sign-up/form', function (hooks) {
setupRenderingTest(hooks);

skip('It should have label', async function (assert) {
assert.expect(1);

this.set('label', 'Form Label');
await render(hbs`
<SignUp::Form
@label={{this.label}}
/>
`);

assert.dom('[data-test-signup-form-label]').hasText(this.label);
});

skip('It should have button with text', async function (assert) {
assert.expect(2);

await render(hbs`<SignUp::Form /> `);

assert.dom('[data-test-signup-button]').exists();
assert.dom('[data-test-signup-button]').hasAnyText();
});

skip('It should have input field', async function (assert) {
assert.expect(3);

await render(hbs`<SignUp::Form /> `);

assert.dom('[data-test-signup-form-input]').exists();
assert
.dom('[data-test-signup-form-input]')
.hasProperty('type', 'text')
.hasAttribute('placeholder');
});
});
26 changes: 26 additions & 0 deletions tests/integration/components/sign-up/get-started-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { module, skip } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | sign-up/get-started', function (hooks) {
setupRenderingTest(hooks);

skip('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`<SignUp::GetStarted />`);

assert.equal(this.element.textContent.trim(), '');

// Template block usage:
await render(hbs`
<SignUp::GetStarted>
template block text
</SignUp::GetStarted>
`);

assert.equal(this.element.textContent.trim(), 'template block text');
});
});