test: add edge case tests
This commit is contained in:
@@ -195,4 +195,52 @@ describe("FsTaskRepository", () => {
|
||||
expect(tasks[0].id).not.toBe(first.id);
|
||||
expect(tasks[0].description).toBe("second");
|
||||
});
|
||||
|
||||
it("creates task with Cyrillic title and slug", async () => {
|
||||
const task = await repo.create(folder, {
|
||||
...sampleTask,
|
||||
title: "Тестовая задача",
|
||||
});
|
||||
expect(task.title).toBe("Тестовая задача");
|
||||
|
||||
const files = await fs.readdir(folder);
|
||||
expect(files).toEqual([`тестовая-задача${TASK_FILE_EXTENSION}`]);
|
||||
});
|
||||
|
||||
it("creates task with title exactly at MAX_TASK_TITLE_LENGTH", async () => {
|
||||
const title = "a".repeat(80);
|
||||
const task = await repo.create(folder, { ...sampleTask, title });
|
||||
expect(task.title).toBe(title);
|
||||
|
||||
const files = await fs.readdir(folder);
|
||||
expect(files).toEqual([`${title}${TASK_FILE_EXTENSION}`]);
|
||||
|
||||
const found = await repo.getById(folder, task.id);
|
||||
expect(found?.title).toBe(title);
|
||||
});
|
||||
|
||||
it("creates task with tags containing special characters", async () => {
|
||||
const task = await repo.create(folder, {
|
||||
...sampleTask,
|
||||
tags: ["c#", "c++", "tag name", "tag:value"],
|
||||
});
|
||||
|
||||
const files = await fs.readdir(folder);
|
||||
expect(files).toHaveLength(1);
|
||||
|
||||
const content = await fs.readFile(
|
||||
`${folder}/fix-login-bug${TASK_FILE_EXTENSION}`,
|
||||
);
|
||||
expect(content).toContain("c#");
|
||||
expect(content).toContain("tag:value");
|
||||
});
|
||||
|
||||
it("getFilePath produces consistent slug regardless of special characters", async () => {
|
||||
const task = await repo.create(folder, {
|
||||
...sampleTask,
|
||||
title: "Fix___bug...",
|
||||
});
|
||||
const files = await fs.readdir(folder);
|
||||
expect(files).toEqual([`fix-bug${TASK_FILE_EXTENSION}`]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user