-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(modal): fix modal event handling and add some tests
- Loading branch information
Showing
5 changed files
with
80 additions
and
37 deletions.
There are no files selected for viewing
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
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
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,28 +1,58 @@ | ||
import { module, test } from "qunit"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { render } from "@ember/test-helpers"; | ||
import { render, settled, triggerKeyEvent } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
|
||
module("Integration | Component | uk-modal", function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test("it doesn't render by default", async function(assert) { | ||
assert.expect(1); | ||
|
||
await render(hbs` | ||
{{#uk-modal}} | ||
<h2>Test</h2> | ||
{{/uk-modal}} | ||
`); | ||
|
||
assert.dom(".uk-modal").hasText("Test"); | ||
await settled(); | ||
|
||
assert.dom(".uk-modal.uk-open").doesNotExist(); | ||
}); | ||
|
||
test("it renders if visible=true", async function(assert) { | ||
assert.expect(1); | ||
|
||
await render(hbs` | ||
{{#uk-modal visible=true}} | ||
<h2>Test</h2> | ||
{{/uk-modal}} | ||
`); | ||
|
||
await settled(); | ||
|
||
assert.dom(".uk-modal.uk-open").exists(); | ||
}); | ||
|
||
test("it triggers the on-hide action", async function(assert) { | ||
assert.expect(3); | ||
|
||
this.set("hide", assert.step("hide")); | ||
|
||
await render(hbs` | ||
{{#uk-modal visible="true"}} | ||
{{#uk-modal visible=true on-hide=hide}} | ||
<h2>Test</h2> | ||
{{/uk-modal}} | ||
`); | ||
|
||
assert.dom(".uk-modal").hasText("Test"); | ||
await settled(); | ||
|
||
// close by pressing esc | ||
await triggerKeyEvent(".uk-modal", "keydown", 27); | ||
|
||
await settled(); | ||
|
||
assert.dom(".uk-modal.uk-open").doesNotExist(); | ||
assert.verifySteps(["hide"]); | ||
}); | ||
}); |