-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9386741
commit 07cacf5
Showing
50 changed files
with
1,567 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
--- | ||
SHD_CLIENT_IMAGE: ghcr.io/hpi-schul-cloud/shd-client | ||
SHD_CLIENT_PREFIX: shd2- | ||
SHD_CLIENT_PREFIX: superhero- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
--- | ||
SHD_CLIENT_IMAGE: quay.io/schulcloudverbund/shd-client | ||
SHD_CLIENT_PREFIX: dashboard2. | ||
SHD_CLIENT_PREFIX: superhero. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
export default { | ||
"common.actions.login": "Anmelden", | ||
"common.actions.logout": "Abmelden", | ||
"common.words.emailAddress": "E-Mail Adresse", | ||
"common.words.password": "Passwort", | ||
"error.generic": "Ein Fehler ist aufgetreten", | ||
"error.load": "Fehler beim Laden der Daten.", | ||
"error.load": "Fehler beim Laden der Daten", | ||
"error.login.noSuperhero": "Der ausgewählte Account ist kein Superhero", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
export default { | ||
"common.actions.login": "Log in", | ||
"common.actions.logout": "Log out", | ||
"common.words.emailAddress": "E-Mail Address", | ||
"common.words.password": "Password", | ||
"error.generic": "An error has occurred", | ||
"error.load": "Error while loading the data.", | ||
"error.load": "Error while loading the data", | ||
"error.login.noSuperhero": "The selected account is not a superhero", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
export default { | ||
"common.actions.login": "Conectarse", | ||
"common.actions.logout": "Cerrar sesión", | ||
"common.words.emailAddress": "Correo electrónico", | ||
"common.words.password": "Contraseña", | ||
"error.generic": "Se ha producido un error", | ||
"error.load": "Error al cargar los datos.", | ||
"error.load": "Error al cargar los datos", | ||
"error.login.noSuperhero": "La cuenta seleccionada no es un superhéroe", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
export default { | ||
"common.actions.login": "зареєструватися", | ||
"common.actions.logout": "Вийти", | ||
"common.words.emailAddress": "адреса електронної пошти", | ||
"common.words.password": "пароль", | ||
"error.generic": "Виникла помилка", | ||
"error.load": "Помилка під час завантаження даних.", | ||
"error.load": "Помилка під час завантаження даних", | ||
"error.login.noSuperhero": "Вибраний обліковий запис не є супергероєм", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
src/modules/data/application-error/applicationError.unit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { defaultApiError, mapAxiosErrorToResponseError } from "@/utils/api"; | ||
import { | ||
apiResponseErrorFactory, | ||
applicationErrorFactory, | ||
axiosErrorFactory, | ||
} from "@@/tests/test-utils/factory"; | ||
import { ApplicationError } from "./applicationError"; | ||
|
||
describe(ApplicationError.name, () => { | ||
describe("fromUnknown", () => { | ||
describe("when the error is already an application error", () => { | ||
const setup = () => { | ||
const error = applicationErrorFactory.build(); | ||
|
||
return { | ||
error, | ||
}; | ||
}; | ||
|
||
it("should return the application error", () => { | ||
const { error } = setup(); | ||
|
||
const result = ApplicationError.fromUnknown(error); | ||
|
||
expect(result).toEqual<ApplicationError>(error); | ||
}); | ||
}); | ||
|
||
describe("when the error is an axios error", () => { | ||
const setup = () => { | ||
const error = axiosErrorFactory.build(); | ||
|
||
return { | ||
error, | ||
}; | ||
}; | ||
|
||
it("should return an application error from the api error", () => { | ||
const { error } = setup(); | ||
|
||
const result = ApplicationError.fromUnknown(error); | ||
|
||
expect(result).toEqual<ApplicationError>( | ||
ApplicationError.fromApiError(mapAxiosErrorToResponseError(error)) | ||
); | ||
}); | ||
}); | ||
|
||
describe("when the error is not a known type", () => { | ||
const setup = () => { | ||
const error = new Error("test"); | ||
|
||
return { | ||
error, | ||
}; | ||
}; | ||
|
||
it("should return a generic application error from the default api error", () => { | ||
const { error } = setup(); | ||
|
||
const result = ApplicationError.fromUnknown(error); | ||
|
||
expect(result).toEqual<ApplicationError>( | ||
new ApplicationError({ | ||
statusCode: defaultApiError.code, | ||
message: `${defaultApiError.title}: ${defaultApiError.message}`, | ||
translationKey: "error.generic", | ||
}) | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("fromApiError", () => { | ||
describe("when using the default translation key", () => { | ||
const setup = () => { | ||
const apiError = apiResponseErrorFactory.build(); | ||
|
||
return { | ||
apiError, | ||
}; | ||
}; | ||
|
||
it("should return an application error with a generic message", () => { | ||
const { apiError } = setup(); | ||
|
||
const result = ApplicationError.fromApiError(apiError); | ||
|
||
expect(result).toEqual<ApplicationError>( | ||
new ApplicationError({ | ||
statusCode: apiError.code, | ||
message: `${apiError.title}: ${apiError.message}`, | ||
translationKey: "error.generic", | ||
}) | ||
); | ||
}); | ||
}); | ||
|
||
describe("when specifying a translation key", () => { | ||
const setup = () => { | ||
const apiError = apiResponseErrorFactory.build(); | ||
|
||
return { | ||
apiError, | ||
}; | ||
}; | ||
|
||
it("should return an application error with the translation key", () => { | ||
const { apiError } = setup(); | ||
|
||
const result = ApplicationError.fromApiError( | ||
apiError, | ||
"error.not.generic" | ||
); | ||
|
||
expect(result).toEqual<ApplicationError>( | ||
new ApplicationError({ | ||
statusCode: apiError.code, | ||
message: `${apiError.title}: ${apiError.message}`, | ||
translationKey: "error.not.generic", | ||
}) | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.