25 lines
828 B
TypeScript
25 lines
828 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { ArticleNotFoundError } from "./article";
|
|
import { InputParseError } from "./common";
|
|
|
|
describe("ArticleNotFoundError", () => {
|
|
it("uses the default message when none is given", () => {
|
|
const err = new ArticleNotFoundError();
|
|
expect(err).toBeInstanceOf(Error);
|
|
expect(err.message).toBe("Article not found");
|
|
});
|
|
|
|
it("uses a custom message when provided", () => {
|
|
const err = new ArticleNotFoundError("could not find article abc");
|
|
expect(err.message).toBe("could not find article abc");
|
|
});
|
|
});
|
|
|
|
describe("InputParseError", () => {
|
|
it("is an instance of Error with the given message", () => {
|
|
const err = new InputParseError("invalid input");
|
|
expect(err).toBeInstanceOf(Error);
|
|
expect(err.message).toBe("invalid input");
|
|
});
|
|
});
|