Update tests, formatting
parent
dda1753c4c
commit
ee0cf9ecf0
|
@ -65,8 +65,8 @@ describe("<ChangePassword/>", function () {
|
|||
new_password_confirmation: "a"
|
||||
};
|
||||
instance().save();
|
||||
expect(error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Password not changed"));
|
||||
const expectation = expect.stringContaining("Password not changed");
|
||||
expect(error).toHaveBeenCalledWith(expectation, "Error");
|
||||
expect(instance().state.status).toBe(SpecialStatus.SAVED);
|
||||
});
|
||||
|
||||
|
@ -78,8 +78,8 @@ describe("<ChangePassword/>", function () {
|
|||
new_password_confirmation: "c"
|
||||
};
|
||||
instance().save();
|
||||
expect(error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("do not match"));
|
||||
const expectation = expect.stringContaining("do not match");
|
||||
expect(error).toHaveBeenCalledWith(expectation, "Error");
|
||||
expect(instance().state.status).toBe(SpecialStatus.SAVED);
|
||||
});
|
||||
|
||||
|
|
|
@ -53,10 +53,10 @@ export class ChangePassword extends React.Component<{}, ChangePWState> {
|
|||
Axios
|
||||
.patch(API.current.usersPath, this.state.form)
|
||||
.then(() => {
|
||||
success(t("Your password is changed."),t("Success"));
|
||||
success(t("Your password is changed."), t("Success"));
|
||||
this.clearForm();
|
||||
}, (e) => {
|
||||
error(e ? prettyPrintApiErrors(e) : t("Password change failed."),t("Error"));
|
||||
error(e ? prettyPrintApiErrors(e) : t("Password change failed."), t("Error"));
|
||||
this.clearForm();
|
||||
});
|
||||
|
||||
|
@ -64,7 +64,7 @@ export class ChangePassword extends React.Component<{}, ChangePWState> {
|
|||
const numUniqueValues = uniq(Object.values(this.state.form)).length;
|
||||
switch (numUniqueValues) {
|
||||
case 1:
|
||||
error(t("Provided new and old passwords match. Password not changed."),t("Error"));
|
||||
error(t("Provided new and old passwords match. Password not changed."), t("Error"));
|
||||
this.clearForm();
|
||||
break;
|
||||
case 2:
|
||||
|
@ -75,7 +75,7 @@ export class ChangePassword extends React.Component<{}, ChangePWState> {
|
|||
this.clearForm();
|
||||
break;
|
||||
case 3:
|
||||
error(t("New password and confirmation do not match."),t("Error"));
|
||||
error(t("New password and confirmation do not match."), t("Error"));
|
||||
this.clearForm();
|
||||
break;
|
||||
default:
|
||||
|
@ -123,4 +123,4 @@ export class ChangePassword extends React.Component<{}, ChangePWState> {
|
|||
</WidgetBody>
|
||||
</Widget>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue