forked from fahrPool/fahrPool
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { validateLogin } from "./validate-login";
|
|
|
|
describe("validateLogin", () => {
|
|
it("akzeptiert eine gueltige E-Mail und Passwort", () => {
|
|
const result = validateLogin({ identifier: "admin@example.com", password: "geheim123" });
|
|
expect(result).toEqual({
|
|
valid: true,
|
|
identifier: "admin@example.com",
|
|
password: "geheim123",
|
|
});
|
|
});
|
|
|
|
it("akzeptiert einen Benutzernamen ohne @", () => {
|
|
const result = validateLogin({ identifier: "anna.fahrer", password: "geheim123" });
|
|
expect(result).toEqual({
|
|
valid: true,
|
|
identifier: "anna.fahrer",
|
|
password: "geheim123",
|
|
});
|
|
});
|
|
|
|
it("lehnt einen fehlenden Identifier ab", () => {
|
|
const result = validateLogin({ identifier: "", password: "geheim123" });
|
|
expect(result).toEqual({
|
|
valid: false,
|
|
error: "Bitte E-Mail oder Benutzernamen eingeben.",
|
|
});
|
|
});
|
|
|
|
it("lehnt ein fehlendes Passwort ab", () => {
|
|
const result = validateLogin({ identifier: "admin@example.com", password: "" });
|
|
expect(result).toEqual({
|
|
valid: false,
|
|
error: "Bitte ein Passwort eingeben.",
|
|
});
|
|
});
|
|
|
|
it("trimmt Leerzeichen im Identifier", () => {
|
|
const result = validateLogin({ identifier: " admin@example.com ", password: "geheim123" });
|
|
expect(result).toEqual({
|
|
valid: true,
|
|
identifier: "admin@example.com",
|
|
password: "geheim123",
|
|
});
|
|
});
|
|
});
|