Skip to content

Commit

Permalink
DEV: Minor cleanup of create-account tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CvX committed Nov 24, 2021
1 parent e217364 commit 6010f65
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";

discourseModule("Unit | Controller | create-account", function () {
test("basicUsernameValidation", async function (assert) {
const testInvalidUsername = async (username, expectedReason) => {
test("basicUsernameValidation", function (assert) {
const testInvalidUsername = (username, expectedReason) => {
const controller = this.getController("create-account");
controller.set("accountUsername", username);

Expand All @@ -24,8 +24,7 @@ discourseModule("Unit | Controller | create-account", function () {
I18n.t("user.username.too_long")
);

const controller = await this.owner.lookup("controller:create-account");
controller.setProperties({
const controller = this.getController("create-account", {
accountUsername: "porkchops",
prefilledUsername: "porkchops",
});
Expand All @@ -39,7 +38,7 @@ discourseModule("Unit | Controller | create-account", function () {
);
});

test("passwordValidation", async function (assert) {
test("passwordValidation", function (assert) {
const controller = this.getController("create-account");

controller.set("authProvider", "");
Expand All @@ -49,12 +48,12 @@ discourseModule("Unit | Controller | create-account", function () {
controller.set("accountPassword", "b4fcdae11f9167");

assert.strictEqual(
controller.get("passwordValidation.ok"),
controller.passwordValidation.ok,
true,
"Password is ok"
);
assert.strictEqual(
controller.get("passwordValidation.reason"),
controller.passwordValidation.reason,
I18n.t("user.password.ok"),
"Password is valid"
);
Expand All @@ -63,12 +62,12 @@ discourseModule("Unit | Controller | create-account", function () {
controller.set("accountPassword", password);

assert.strictEqual(
controller.get("passwordValidation.failed"),
controller.passwordValidation.failed,
true,
"password should be invalid: " + password
);
assert.strictEqual(
controller.get("passwordValidation.reason"),
controller.passwordValidation.reason,
expectedReason,
"password validation reason: " + password + ", " + expectedReason
);
Expand All @@ -83,8 +82,8 @@ discourseModule("Unit | Controller | create-account", function () {
);
});

test("authProviderDisplayName", async function (assert) {
const controller = this.owner.lookup("controller:create-account");
test("authProviderDisplayName", function (assert) {
const controller = this.getController("create-account");

assert.strictEqual(
controller.authProviderDisplayName("facebook"),
Expand Down

0 comments on commit 6010f65

Please sign in to comment.