mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
DEV: migrate components tests to async/await
This commit is contained in:
@ -3,7 +3,7 @@ moduleForComponent("value-list", { integration: true });
|
||||
|
||||
componentTest("functionality", {
|
||||
template: '{{value-list values=values inputType="array"}}',
|
||||
test(assert) {
|
||||
async test(assert) {
|
||||
assert.ok(this.$(".values .value").length === 0, "it has no values");
|
||||
assert.ok(this.$("input").length, "it renders the input");
|
||||
assert.ok(
|
||||
@ -11,29 +11,20 @@ componentTest("functionality", {
|
||||
"it is disabled with no value"
|
||||
);
|
||||
|
||||
fillIn("input", "eviltrout");
|
||||
andThen(() => {
|
||||
assert.ok(
|
||||
!this.$(".btn-primary[disabled]").length,
|
||||
"it isn't disabled anymore"
|
||||
);
|
||||
});
|
||||
await fillIn("input", "eviltrout");
|
||||
assert.ok(
|
||||
!this.$(".btn-primary[disabled]").length,
|
||||
"it isn't disabled anymore"
|
||||
);
|
||||
|
||||
click(".btn-primary");
|
||||
andThen(() => {
|
||||
assert.equal(this.$(".values .value").length, 1, "it adds the value");
|
||||
assert.equal(this.$("input").val(), "", "it clears the input");
|
||||
assert.ok(
|
||||
this.$(".btn-primary[disabled]").length,
|
||||
"it is disabled again"
|
||||
);
|
||||
assert.equal(this.get("values"), "eviltrout", "it appends the value");
|
||||
});
|
||||
await click(".btn-primary");
|
||||
assert.equal(this.$(".values .value").length, 1, "it adds the value");
|
||||
assert.equal(this.$("input").val(), "", "it clears the input");
|
||||
assert.ok(this.$(".btn-primary[disabled]").length, "it is disabled again");
|
||||
assert.equal(this.get("values"), "eviltrout", "it appends the value");
|
||||
|
||||
click(".value .btn-small");
|
||||
andThen(() => {
|
||||
assert.ok(this.$(".values .value").length === 0, "it removes the value");
|
||||
});
|
||||
await click(".value .btn-small");
|
||||
assert.ok(this.$(".values .value").length === 0, "it removes the value");
|
||||
}
|
||||
});
|
||||
|
||||
@ -43,16 +34,14 @@ componentTest("with string delimited values", {
|
||||
this.set("valueString", "hello\nworld");
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
async test(assert) {
|
||||
assert.equal(this.$(".values .value").length, 2);
|
||||
|
||||
fillIn("input", "eviltrout");
|
||||
click(".btn-primary");
|
||||
await fillIn("input", "eviltrout");
|
||||
await click(".btn-primary");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(this.$(".values .value").length, 3);
|
||||
assert.equal(this.get("valueString"), "hello\nworld\neviltrout");
|
||||
});
|
||||
assert.equal(this.$(".values .value").length, 3);
|
||||
assert.equal(this.get("valueString"), "hello\nworld\neviltrout");
|
||||
}
|
||||
});
|
||||
|
||||
@ -62,15 +51,13 @@ componentTest("with array values", {
|
||||
this.set("valueArray", ["abc", "def"]);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
async test(assert) {
|
||||
assert.equal(this.$(".values .value").length, 2);
|
||||
|
||||
fillIn("input", "eviltrout");
|
||||
click(".btn-primary");
|
||||
await fillIn("input", "eviltrout");
|
||||
await click(".btn-primary");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(this.$(".values .value").length, 3);
|
||||
assert.deepEqual(this.get("valueArray"), ["abc", "def", "eviltrout"]);
|
||||
});
|
||||
assert.equal(this.$(".values .value").length, 3);
|
||||
assert.deepEqual(this.get("valueArray"), ["abc", "def", "eviltrout"]);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user