-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from zfir-dev/first-tests
First tests
- Loading branch information
Showing
12 changed files
with
74 additions
and
15 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
<!-- app/components/input-modal.hbs --> | ||
{{!-- app/components/input-modal.hbs --}} | ||
<div class="input-modal"> | ||
<div class="modal-content"> | ||
<button {{on "click" this.closeModal}}>X</button> | ||
<label>First Name</label> | ||
<input type="text" value={{this.firstName}} {{on "input" this.updateFirstName}} /> | ||
<button type="button" {{on "click" this.closeModal}}>X</button> | ||
<label for="first-name">First Name</label> | ||
<input id="first-name" type="text" value={{this.firstName}} {{on "input" this.updateFirstName}} /> | ||
|
||
<label>Last Name</label> | ||
<input type="text" value={{this.lastName}} {{on "input" this.updateLastName}} /> | ||
<label for="last-name">Last Name</label> | ||
<input id="last-name" type="text" value={{this.lastName}} {{on "input" this.updateLastName}} /> | ||
|
||
<label>Email</label> | ||
<input type="email" value={{this.email}} {{on "input" this.updateEmail}} /> | ||
|
||
<button {{on "click" this.save}}>Save</button> | ||
<label for="email">Email</label> | ||
<input id="email" type="email" value={{this.email}} {{on "input" this.updateEmail}} /> | ||
<button type="button" {{on "click" this.save}}>Save</button> | ||
</div> | ||
</div> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!-- app/components/open-modal-button.hbs --> | ||
<button {{on "click" this.openModal}}>Open Modal</button> | ||
{{!-- app/components/open-modal-button.hbs --}} | ||
<button type="button" {{on "click" this.openModal}}>Open Modal</button> | ||
{{#if this.isModalOpen}} | ||
<InputModal @closeModal={{this.closeModal}} /> | ||
{{/if}} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!-- app/templates/application.hbs --> | ||
{{!-- app/templates/application.hbs --}} | ||
<h2>Welcome to DevCon 2024 Ember.js Test Demo</h2> | ||
<OpenModalButton /> | ||
{{outlet}} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// tests/integration/components/input-modal-test.ts | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('Integration | Component | input-modal', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders input fields, a close button and a save button', async function (assert) { | ||
await render(hbs`<InputModal />`); | ||
assert.dom('input[type="text"]:nth-of-type(1)').exists(); | ||
assert.dom('input[type="text"]:nth-of-type(2)').exists(); | ||
assert.dom('input[type="email"]').exists(); | ||
assert.dom('button:nth-of-type(1)').hasText('X'); | ||
assert.dom('button:nth-of-type(2)').hasText('Save'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// tests/integration/components/input-modal-test.ts | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { click, findAll, render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('Integration | Component | open-modal-button', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders the open modal button', async function (assert) { | ||
await render(hbs`<OpenModalButton />`); | ||
assert.dom('button').hasText('Open Modal'); | ||
}); | ||
|
||
test('it opens the modal when the button is clicked', async function (assert) { | ||
await render(hbs`<OpenModalButton />`); | ||
assert.dom('input[type="text"]:nth-of-type(1)').doesNotExist(); | ||
assert.strictEqual( | ||
findAll('button').filter((btn) => btn.textContent?.trim() === 'Save') | ||
.length, | ||
0, | ||
'Save button does not exist before clicking', | ||
); | ||
await click('button'); | ||
assert.dom('input[type="text"]:nth-of-type(1)').exists(); | ||
assert.strictEqual( | ||
findAll('button').filter((btn) => btn.textContent?.trim() === 'Save') | ||
.length, | ||
1, | ||
'Save button exists after clicking', | ||
); | ||
}); | ||
}); |
File renamed without changes.