feat: add inline icons for edit
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Task } from "@/model/task";
|
||||
import { ITaskRepository } from "@/ports";
|
||||
import { TASK_FILE_EXTENSION } from "@/model/taskFile";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { InMemoryFileSystem } from "../../tests/helpers/InMemoryFileSystem";
|
||||
import { FsTaskRepository } from "./FsTaskRepository";
|
||||
@@ -30,14 +31,14 @@ describe("FsTaskRepository", () => {
|
||||
fs = new InMemoryFileSystem();
|
||||
clockStep = 0;
|
||||
const timestamps = [t0, t1, t2];
|
||||
repo = new FsTaskRepository(fs, ".task.md", () => {
|
||||
repo = new FsTaskRepository(fs, TASK_FILE_EXTENSION, () => {
|
||||
const value = timestamps[clockStep] ?? t2;
|
||||
clockStep += 1;
|
||||
return value;
|
||||
});
|
||||
});
|
||||
|
||||
it("creates a task and writes it as a .task.md file", async () => {
|
||||
it("creates a task and writes it as a task file", async () => {
|
||||
const task = await repo.create(folder, sampleTask);
|
||||
|
||||
expect(task.id).toMatch(UUID_RE);
|
||||
@@ -46,9 +47,11 @@ describe("FsTaskRepository", () => {
|
||||
expect(task.updated).toBe(t0);
|
||||
|
||||
const files = await fs.readdir(folder);
|
||||
expect(files).toEqual(["fix-login-bug.task.md"]);
|
||||
expect(files).toEqual([`fix-login-bug${TASK_FILE_EXTENSION}`]);
|
||||
|
||||
const content = await fs.readFile(`${folder}/fix-login-bug.task.md`);
|
||||
const content = await fs.readFile(
|
||||
`${folder}/fix-login-bug${TASK_FILE_EXTENSION}`,
|
||||
);
|
||||
expect(content).toContain("Fix login bug");
|
||||
expect(content).toContain("status: todo");
|
||||
});
|
||||
@@ -91,12 +94,14 @@ describe("FsTaskRepository", () => {
|
||||
|
||||
it("update renames file when title changes", async () => {
|
||||
const task = await repo.create(folder, sampleTask);
|
||||
expect(await fs.readdir(folder)).toEqual(["fix-login-bug.task.md"]);
|
||||
expect(await fs.readdir(folder)).toEqual([
|
||||
`fix-login-bug${TASK_FILE_EXTENSION}`,
|
||||
]);
|
||||
|
||||
await repo.update(folder, { ...task, title: "Fixed!" });
|
||||
|
||||
const files = await fs.readdir(folder);
|
||||
expect(files).toEqual(["fixed.task.md"]);
|
||||
expect(files).toEqual([`fixed${TASK_FILE_EXTENSION}`]);
|
||||
const found = await repo.getById(folder, task.id);
|
||||
expect(found!.title).toBe("Fixed!");
|
||||
expect(found!.updated).toBe(t1);
|
||||
@@ -119,7 +124,7 @@ describe("FsTaskRepository", () => {
|
||||
title: "Orphan",
|
||||
updated: t0,
|
||||
});
|
||||
expect(await fs.readdir(folder)).toEqual(["orphan.task.md"]);
|
||||
expect(await fs.readdir(folder)).toEqual([`orphan${TASK_FILE_EXTENSION}`]);
|
||||
});
|
||||
|
||||
it("delete removes the task file", async () => {
|
||||
@@ -159,9 +164,12 @@ describe("FsTaskRepository", () => {
|
||||
});
|
||||
|
||||
it("skips files without id", async () => {
|
||||
await fs.writeFile(`${folder}/no-id.task.md`, "not valid frontmatter");
|
||||
await fs.writeFile(
|
||||
`${folder}/empty-id.task.md`,
|
||||
`${folder}/no-id${TASK_FILE_EXTENSION}`,
|
||||
"not valid frontmatter",
|
||||
);
|
||||
await fs.writeFile(
|
||||
`${folder}/empty-id${TASK_FILE_EXTENSION}`,
|
||||
"---\ntitle: No Id\n---\n",
|
||||
);
|
||||
|
||||
@@ -179,7 +187,7 @@ describe("FsTaskRepository", () => {
|
||||
});
|
||||
|
||||
const files = await fs.readdir(folder);
|
||||
expect(files).toEqual(["fix-login-bug.task.md"]);
|
||||
expect(files).toEqual([`fix-login-bug${TASK_FILE_EXTENSION}`]);
|
||||
|
||||
const tasks = await repo.list(folder);
|
||||
expect(tasks).toHaveLength(1);
|
||||
|
||||
Reference in New Issue
Block a user