summaryrefslogtreecommitdiffhomepage
path: root/packages/todo/src/format.test.ts
blob: bffb8a304e371512114c1da5b009c025e53da696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { describe, expect, it } from "vitest";
import { formatTodoResult, type TodoItem } from "./pure.js";

describe("formatTodoResult", () => {
	it("formatTodoResult: returns JSON string of the todos", () => {
		const todos: TodoItem[] = [
			{ content: "alpha", status: "in_progress" },
			{ content: "beta", status: "pending" },
		];
		expect(formatTodoResult(todos)).toBe(JSON.stringify(todos, null, 2));
		// spot-check it is pretty-printed JSON (indented key)
		expect(formatTodoResult(todos)).toContain('"content": "alpha"');
	});

	it('formatTodoResult: empty array returns "[]"', () => {
		expect(formatTodoResult([])).toBe("[]");
	});
});