DEV: apply new coding standards (#10592)

This commit is contained in:
Joffrey JAFFEUX
2020-09-04 13:42:47 +02:00
committed by GitHub
parent 80dfaeb0d2
commit 52672b9eab
1473 changed files with 9386 additions and 9958 deletions
+51 -61
View File
@@ -14,7 +14,7 @@ widgetTest("widget attributes are passed in via args", {
beforeEach() {
createWidget("hello-test", {
tagName: "div.test",
template: hbs`Hello {{attrs.name}}`
template: hbs`Hello {{attrs.name}}`,
});
this.set("args", { name: "Robin" });
@@ -22,7 +22,7 @@ widgetTest("widget attributes are passed in via args", {
test(assert) {
assert.equal(find(".test").text(), "Hello Robin");
}
},
});
widgetTest("hbs template - no tagName", {
@@ -30,7 +30,7 @@ widgetTest("hbs template - no tagName", {
beforeEach() {
createWidget("hbs-test", {
template: hbs`<div class='test'>Hello {{attrs.name}}</div>`
template: hbs`<div class='test'>Hello {{attrs.name}}</div>`,
});
this.set("args", { name: "Robin" });
@@ -38,7 +38,7 @@ widgetTest("hbs template - no tagName", {
test(assert) {
assert.equal(find("div.test").text(), "Hello Robin");
}
},
});
widgetTest("hbs template - with tagName", {
@@ -47,7 +47,7 @@ widgetTest("hbs template - with tagName", {
beforeEach() {
createWidget("hbs-test", {
tagName: "div.test",
template: hbs`Hello {{attrs.name}}`
template: hbs`Hello {{attrs.name}}`,
});
this.set("args", { name: "Robin" });
@@ -55,7 +55,7 @@ widgetTest("hbs template - with tagName", {
test(assert) {
assert.equal(find("div.test").text(), "Hello Robin");
}
},
});
widgetTest("hbs template - with data attributes", {
@@ -63,13 +63,13 @@ widgetTest("hbs template - with data attributes", {
beforeEach() {
createWidget("hbs-test", {
template: hbs`<div class='mydiv' data-my-test='hello world'></div>`
template: hbs`<div class='mydiv' data-my-test='hello world'></div>`,
});
},
test(assert) {
assert.equal(find("div.mydiv").data("my-test"), "hello world");
}
},
});
widgetTest("buildClasses", {
@@ -81,7 +81,7 @@ widgetTest("buildClasses", {
buildClasses(attrs) {
return ["static", attrs.dynamic];
}
},
});
this.set("args", { dynamic: "cool-class" });
@@ -89,7 +89,7 @@ widgetTest("buildClasses", {
test(assert) {
assert.ok(find(".test.static.cool-class").length, "it has all the classes");
}
},
});
widgetTest("buildAttributes", {
@@ -101,7 +101,7 @@ widgetTest("buildAttributes", {
buildAttributes(attrs) {
return { "data-evil": "trout", "aria-label": attrs.label };
}
},
});
this.set("args", { label: "accessibility" });
@@ -110,7 +110,7 @@ widgetTest("buildAttributes", {
test(assert) {
assert.ok(find(".test[data-evil=trout]").length);
assert.ok(find(".test[aria-label=accessibility]").length);
}
},
});
widgetTest("buildId", {
@@ -120,7 +120,7 @@ widgetTest("buildId", {
createWidget("id-test", {
buildId(attrs) {
return `test-${attrs.id}`;
}
},
});
this.set("args", { id: 1234 });
@@ -128,7 +128,7 @@ widgetTest("buildId", {
test(assert) {
assert.ok(find("#test-1234").length);
}
},
});
widgetTest("widget state", {
@@ -146,7 +146,7 @@ widgetTest("widget state", {
click() {
this.state.clicks++;
}
},
});
},
@@ -156,7 +156,7 @@ widgetTest("widget state", {
await click(find("button"));
assert.equal(find("button.test").text(), "1 clicks");
}
},
});
widgetTest("widget update with promise", {
@@ -175,32 +175,22 @@ widgetTest("widget update with promise", {
`,
click() {
return new Promise(resolve => {
return new Promise((resolve) => {
next(() => {
this.state.name = "Robin";
resolve();
});
});
}
},
});
},
async test(assert) {
assert.equal(
find("button.test")
.text()
.trim(),
"No name"
);
assert.equal(find("button.test").text().trim(), "No name");
await click(find("button"));
assert.equal(
find("button.test")
.text()
.trim(),
"Robin"
);
}
assert.equal(find("button.test").text().trim(), "Robin");
},
});
widgetTest("widget attaching", {
@@ -211,14 +201,14 @@ widgetTest("widget attaching", {
createWidget("attach-test", {
tagName: "div.container",
template: hbs`{{attach widget="test-embedded" attrs=attrs}}`
template: hbs`{{attach widget="test-embedded" attrs=attrs}}`,
});
},
test(assert) {
assert.ok(find(".container").length, "renders container");
assert.ok(find(".container .embedded").length, "renders attached");
}
},
});
widgetTest("magic attaching by name", {
@@ -229,14 +219,14 @@ widgetTest("magic attaching by name", {
createWidget("attach-test", {
tagName: "div.container",
template: hbs`{{test-embedded attrs=attrs}}`
template: hbs`{{test-embedded attrs=attrs}}`,
});
},
test(assert) {
assert.ok(find(".container").length, "renders container");
assert.ok(find(".container .embedded").length, "renders attached");
}
},
});
widgetTest("custom attrs to a magic attached widget", {
@@ -245,19 +235,19 @@ widgetTest("custom attrs to a magic attached widget", {
beforeEach() {
createWidget("testing", {
tagName: "span.value",
template: hbs`{{attrs.value}}`
template: hbs`{{attrs.value}}`,
});
createWidget("attach-test", {
tagName: "div.container",
template: hbs`{{testing value=(concat "hello" " " "world")}}`
template: hbs`{{testing value=(concat "hello" " " "world")}}`,
});
},
test(assert) {
assert.ok(find(".container").length, "renders container");
assert.equal(find(".container .value").text(), "hello world");
}
},
});
widgetTest("handlebars d-icon", {
@@ -265,13 +255,13 @@ widgetTest("handlebars d-icon", {
beforeEach() {
createWidget("hbs-icon-test", {
template: hbs`{{d-icon "arrow-down"}}`
template: hbs`{{d-icon "arrow-down"}}`,
});
},
test(assert) {
assert.equal(find(".d-icon-arrow-down").length, 1);
}
},
});
widgetTest("handlebars i18n", {
@@ -285,15 +275,15 @@ widgetTest("handlebars i18n", {
<span class='string'>{{i18n "hbs_test0"}}</span>
<span class='var'>{{i18n attrs.key}}</span>
<a href title={{i18n "hbs_test0"}}>test</a>
`
`,
});
I18n.translations = {
en: {
js: {
hbs_test0: "evil",
hbs_test1: "trout"
}
}
hbs_test1: "trout",
},
},
};
this.set("args", { key: "hbs_test1" });
},
@@ -307,7 +297,7 @@ widgetTest("handlebars i18n", {
assert.equal(find("span.string").text(), "evil");
assert.equal(find("span.var").text(), "trout");
assert.equal(find("a").prop("title"), "evil");
}
},
});
widgetTest("handlebars #each", {
@@ -320,18 +310,18 @@ widgetTest("handlebars #each", {
{{#each attrs.items as |item|}}
<li>{{item}}</li>
{{/each}}
`
`,
});
this.set("args", {
items: ["one", "two", "three"]
items: ["one", "two", "three"],
});
},
test(assert) {
assert.equal(find("ul li").length, 3);
assert.equal(find("ul li:eq(0)").text(), "one");
}
},
});
widgetTest("widget decorating", {
@@ -340,15 +330,15 @@ widgetTest("widget decorating", {
beforeEach() {
createWidget("decorate-test", {
tagName: "div.decorate",
template: hbs`main content`
template: hbs`main content`,
});
withPluginApi("0.1", api => {
api.decorateWidget("decorate-test:before", dec => {
withPluginApi("0.1", (api) => {
api.decorateWidget("decorate-test:before", (dec) => {
return dec.h("b", "before");
});
api.decorateWidget("decorate-test:after", dec => {
api.decorateWidget("decorate-test:after", (dec) => {
return dec.h("i", "after");
});
});
@@ -358,7 +348,7 @@ widgetTest("widget decorating", {
assert.ok(find(".decorate").length);
assert.equal(find(".decorate b").text(), "before");
assert.equal(find(".decorate i").text(), "after");
}
},
});
widgetTest("widget settings", {
@@ -368,13 +358,13 @@ widgetTest("widget settings", {
createWidget("settings-test", {
tagName: "div.settings",
template: hbs`age is {{settings.age}}`,
settings: { age: 36 }
settings: { age: 36 },
});
},
test(assert) {
assert.equal(find(".settings").text(), "age is 36");
}
},
});
widgetTest("override settings", {
@@ -384,17 +374,17 @@ widgetTest("override settings", {
createWidget("ov-settings-test", {
tagName: "div.settings",
template: hbs`age is {{settings.age}}`,
settings: { age: 36 }
settings: { age: 36 },
});
withPluginApi("0.1", api => {
withPluginApi("0.1", (api) => {
api.changeWidgetSetting("ov-settings-test", "age", 37);
});
},
test(assert) {
assert.equal(find(".settings").text(), "age is 37");
}
},
});
widgetTest("get accessor", {
@@ -406,13 +396,13 @@ widgetTest("get accessor", {
template: hbs`Hello {{transformed.name}}`,
transform() {
return {
name: this.get("currentUser.username")
name: this.get("currentUser.username"),
};
}
},
});
},
test(assert) {
assert.equal(find("div.test").text(), "Hello eviltrout");
}
},
});