Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
test(report-row): refactor component invocation to octane
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabauke committed Dec 20, 2022
1 parent b1338fd commit 20b197b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/components/report-row/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@
data-test-delete-report
class="btn btn-danger"
disabled={{this.report.verifiedBy.id}}
{{on "click" this.delete}}
{{on "click" (fn (optional @onDelete) @report)}}
>{{fa-icon "trash"}}</button>
<button
type="submit"
data-test-save-report
class="btn btn-primary"
disabled={{or (not cs.isDirty) (not cs.isValid)}}
{{on "click" (prevent-default (fn this.save cs))}}
{{on "click" (prevent-default (fn (optional @onSave) cs))}}
>{{fa-icon "save"}}</button>
{{/if}}
</div>
Expand Down
23 changes: 8 additions & 15 deletions tests/integration/components/report-row/component-test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
import EmberObject from "@ember/object";
import { click, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupRenderingTest } from "ember-qunit";
import { module, test } from "qunit";
import { startMirage } from "timed/initializers/ember-cli-mirage";

module("Integration | Component | report row", function (hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function () {
this.server = startMirage();
});

hooks.afterEach(function () {
this.server.shutdown();
});
setupMirage(hooks);

test("renders", async function (assert) {
this.set(
"report",
EmberObject.create({ verifiedBy: EmberObject.create() })
);

await render(hbs`{{report-row report}}`);
await render(hbs`<ReportRow @report={{this.report}}/>`);

assert.dom("form").exists({ count: 1 });
assert.dom(".form-group").exists({ count: 8 });
Expand All @@ -38,10 +31,10 @@ module("Integration | Component | report row", function (hooks) {
this.set("didDelete", false);

await render(hbs`
{{report-row
report
on-delete=(action (mut didDelete) true)
}}
<ReportRow
@report={{this.report}}
@onDelete={{(fn (mut this.didDelete) true)}}
/>
`);

await click(".btn-danger");
Expand All @@ -61,7 +54,7 @@ module("Integration | Component | report row", function (hooks) {
})
);

await render(hbs`{{report-row report}}`);
await render(hbs`<ReportRow @report={{this.report}} />`);

assert.dom("input").isDisabled();
assert.dom("form").hasAttribute("title", /John Doe/);
Expand Down

0 comments on commit 20b197b

Please sign in to comment.