DEV: migrate components tests to async/await

This commit is contained in:
Maja Komel
2018-07-24 20:12:09 +02:00
parent c0992a4d31
commit d16a2c776a
10 changed files with 619 additions and 615 deletions

View File

@ -7,73 +7,69 @@ moduleForComponent("admin-report", {
componentTest("default", {
template: "{{admin-report dataSourceName='signups'}}",
test(assert) {
andThen(() => {
assert.ok(exists(".admin-report.signups"));
async test(assert) {
assert.ok(exists(".admin-report.signups"));
assert.ok(
exists(".admin-report.table.signups", "it defaults to table mode")
);
assert.ok(
exists(".admin-report.table.signups", "it defaults to table mode")
);
assert.equal(
find(".report-header .title")
.text()
.trim(),
"Signups",
"it has a title"
);
assert.equal(
find(".report-header .title")
.text()
.trim(),
"Signups",
"it has a title"
);
assert.equal(
find(".report-header .info").attr("data-tooltip"),
"New account registrations for this period",
"it has a description"
);
assert.equal(
find(".report-header .info").attr("data-tooltip"),
"New account registrations for this period",
"it has a description"
);
assert.equal(
find(".report-body .report-table thead tr th:first-child")
.text()
.trim(),
"Day",
"it has col headers"
);
assert.equal(
find(".report-body .report-table thead tr th:first-child")
.text()
.trim(),
"Day",
"it has col headers"
);
assert.equal(
find(".report-body .report-table thead tr th:nth-child(2)")
.text()
.trim(),
"Count",
"it has col headers"
);
assert.equal(
find(".report-body .report-table thead tr th:nth-child(2)")
.text()
.trim(),
"Count",
"it has col headers"
);
assert.equal(
find(".report-body .report-table tbody tr:nth-child(1) td:nth-child(1)")
.text()
.trim(),
"June 16, 2018",
"it has rows"
);
assert.equal(
find(".report-body .report-table tbody tr:nth-child(1) td:nth-child(1)")
.text()
.trim(),
"June 16, 2018",
"it has rows"
);
assert.equal(
find(".report-body .report-table tbody tr:nth-child(1) td:nth-child(2)")
.text()
.trim(),
"12",
"it has rows"
);
assert.equal(
find(".report-body .report-table tbody tr:nth-child(1) td:nth-child(2)")
.text()
.trim(),
"12",
"it has rows"
);
assert.ok(exists(".totals-sample-table"), "it has totals");
});
assert.ok(exists(".totals-sample-table"), "it has totals");
click(".admin-report-table-header.y .sort-button");
andThen(() => {
assert.equal(
find(".report-body .report-table tbody tr:nth-child(1) td:nth-child(2)")
.text()
.trim(),
"7",
"it can sort rows"
);
});
await click(".admin-report-table-header.y .sort-button");
assert.equal(
find(".report-body .report-table tbody tr:nth-child(1) td:nth-child(2)")
.text()
.trim(),
"7",
"it can sort rows"
);
}
});
@ -90,32 +86,25 @@ componentTest("options", {
},
test(assert) {
andThen(() => {
assert.ok(exists(".pagination"), "it paginates the results");
assert.equal(
find(".pagination button").length,
3,
"it creates the correct number of pages"
);
assert.ok(exists(".pagination"), "it paginates the results");
assert.equal(
find(".pagination button").length,
3,
"it creates the correct number of pages"
);
assert.notOk(exists(".totals-sample-table"), "it hides totals");
});
assert.notOk(exists(".totals-sample-table"), "it hides totals");
}
});
componentTest("switch modes", {
template: "{{admin-report dataSourceName='signups'}}",
test(assert) {
click(".mode-button.chart");
async test(assert) {
await click(".mode-button.chart");
andThen(() => {
assert.notOk(
exists(".admin-report.table.signups"),
"it removes the table"
);
assert.ok(exists(".admin-report.chart.signups"), "it shows the chart");
});
assert.notOk(exists(".admin-report.table.signups"), "it removes the table");
assert.ok(exists(".admin-report.chart.signups"), "it shows the chart");
}
});
@ -123,8 +112,6 @@ componentTest("timeout", {
template: "{{admin-report dataSourceName='signups_timeout'}}",
test(assert) {
andThen(() => {
assert.ok(exists(".alert-error"), "it displays a timeout error");
});
assert.ok(exists(".alert-error"), "it displays a timeout error");
}
});