-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: re-write tests to use modern Ember features
BREAKING CHANGE: Error about missing component is no longer swallowed in Production
- Loading branch information
1 parent
c625e69
commit 7602d25
Showing
19 changed files
with
418 additions
and
505 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,3 +1,3 @@ | ||
import Ember from "ember"; | ||
import Component from "@ember/component"; | ||
|
||
export default Ember.Component.extend(); | ||
export default Component.extend(); |
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,93 +1,49 @@ | ||
import Ember from "ember"; | ||
import { module, test } from "qunit"; | ||
import startApp from "../helpers/start-app"; | ||
import { setupApplicationTest } from "ember-qunit"; | ||
import { click, getRootElement, visit } from "@ember/test-helpers"; | ||
|
||
var application; | ||
module("Acceptance | Rendering Components", function (hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
module("Acceptance: Rendering Components", { | ||
beforeEach: function () { | ||
hooks.beforeEach(function () { | ||
// Put some static content on the page before the Ember application loads. | ||
// This mimics server-rendered content. | ||
document.getElementById("ember-testing").innerHTML = ` | ||
getRootElement().innerHTML = ` | ||
<p>server-rendered content top</p> | ||
<div data-component='top-level-component' data-attrs='{"title": "Component Title"}'></div> | ||
<p>server-rendered content bottom</p> | ||
`; | ||
|
||
application = startApp(); | ||
}, | ||
|
||
afterEach: function () { | ||
Ember.run(application, "destroy"); | ||
document.getElementById("ember-testing").innerHTML = ""; | ||
}, | ||
}); | ||
|
||
test("rendering a component with an attribute", function (assert) { | ||
assert.expect(2); | ||
visit("/"); | ||
|
||
andThen(function () { | ||
assert.equal( | ||
find("p:contains(top level component)").length, | ||
1, | ||
"The top level component was rendered" | ||
); | ||
assert.equal( | ||
find("#component-title:contains(Component Title)").length, | ||
1, | ||
"Passed in attributes can be used" | ||
); | ||
}); | ||
}); | ||
|
||
test("using component events", function (assert) { | ||
assert.expect(2); | ||
visit("/"); | ||
test("rendering a component with an attribute", async function (assert) { | ||
await visit("/"); | ||
|
||
assert | ||
.dom("[data-test-top-level-component-message]") | ||
.exists("The top level component was rendered"); | ||
|
||
andThen(function () { | ||
assert.equal( | ||
find("#expanded-content").length, | ||
0, | ||
"Expanded content is hidden at first" | ||
); | ||
assert | ||
.dom("#component-title") | ||
.includesText("Component Title", "Passed in attributes can be used"); | ||
}); | ||
|
||
click("#toggle-expanded"); | ||
test("using component events", async function (assert) { | ||
await visit("/"); | ||
|
||
andThen(function () { | ||
assert.equal( | ||
find("#expanded-content").length, | ||
1, | ||
"The expanded content is showing" | ||
); | ||
}); | ||
}); | ||
assert | ||
.dom("#expanded-content") | ||
.doesNotExist("Expanded content is hidden at first"); | ||
|
||
test("using nested components", function (assert) { | ||
assert.expect(3); | ||
visit("/"); | ||
await click("#toggle-expanded"); | ||
|
||
andThen(function () { | ||
assert.equal( | ||
find("p:contains(A nested component)").length, | ||
1, | ||
"The nested component was rendered" | ||
); | ||
assert.equal( | ||
find("#expanded-content").length, | ||
0, | ||
"Expanded content is hidden at first" | ||
); | ||
assert.dom("#expanded-content").exists("The expanded content is showing"); | ||
}); | ||
|
||
click("#nested-component-toggle-expanded"); | ||
test("using nested components", async function (assert) { | ||
await visit("/"); | ||
|
||
andThen(function () { | ||
assert.equal( | ||
find("#expanded-content").length, | ||
1, | ||
"The expanded content is showing" | ||
); | ||
assert | ||
.dom("[data-test-nested-component-message]") | ||
.exists("The nested component was rendered"); | ||
}); | ||
}); |
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,5 +1,5 @@ | ||
import Ember from "ember"; | ||
import Component from "@ember/component"; | ||
|
||
export default Ember.Component.extend({ | ||
export default Component.extend({ | ||
classNameBindings: [":inner-content-component"], | ||
}); |
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,3 +1,3 @@ | ||
<p>A nested component</p> | ||
<p data-test-nested-component-message>A nested component</p> | ||
|
||
<button id='nested-component-toggle-expanded' {{action 'nestedAction'}}>Nested component action</button> |
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
Oops, something went wrong.