-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(question-usage): add basic tests
- Loading branch information
1 parent
ff88729
commit 707e48d
Showing
2 changed files
with
58 additions
and
1 deletion.
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
57 changes: 57 additions & 0 deletions
57
packages/form-builder/tests/integration/components/cfb-form-editor/question-usage-test.js
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,57 @@ | ||
import { render, click } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
import { setupMirage } from "ember-cli-mirage/test-support"; | ||
import { setupIntl } from "ember-intl/test-support"; | ||
import { module, test } from "qunit"; | ||
|
||
import { setupRenderingTest } from "dummy/tests/helpers"; | ||
|
||
module( | ||
"Integration | Component | cfb-form-editor/question-usage", | ||
function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupMirage(hooks); | ||
setupIntl(hooks); | ||
|
||
test("it renders", async function (assert) { | ||
this.set( | ||
"question", | ||
this.server.create("question", { | ||
label: "Test Label", | ||
slug: "test-slug", | ||
type: "TEXT", | ||
}), | ||
); | ||
|
||
this.server.createList("form", 3, { questions: [this.question] }); | ||
|
||
await render( | ||
hbs`<CfbFormEditor::QuestionUsage @model={{this.question}} />`, | ||
); | ||
|
||
await click("[data-test-show-question-usage-modal-link]"); | ||
|
||
assert.dom("[data-test-question-usage-modal]").isVisible(); | ||
assert.dom("[data-test-question-form-item]").exists({ count: 3 }); | ||
}); | ||
|
||
test("it is hidden when no other reference to this question exists", async function (assert) { | ||
this.set( | ||
"question", | ||
this.server.create("question", { | ||
label: "Test Label", | ||
slug: "test-slug", | ||
type: "TEXT", | ||
}), | ||
); | ||
|
||
this.server.create("form", { questions: [this.question] }); | ||
|
||
await render( | ||
hbs`<CfbFormEditor::QuestionUsage @model={{this.question}} />`, | ||
); | ||
|
||
assert.dom("[data-test-show-question-usage-modal-link]").isNotVisible(); | ||
}); | ||
}, | ||
); |