{"version":3,"file":"todo-list.test.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/todo-list.test.ts"],"names":[],"mappings":"","sourcesContent":["import { visibleWidth } from \"@apholdings/jensen-tui\";\nimport { beforeAll, describe, expect, it } from \"vitest\";\nimport { initTheme } from \"../theme/theme.js\";\nimport { TodoListComponent } from \"./todo-list.js\";\n\nbeforeAll(() => {\n\tinitTheme(\"dark\");\n});\n\ndescribe(\"TodoListComponent\", () => {\n\tdescribe(\"conditional rendering\", () => {\n\t\tit(\"renders nothing when no todos exist\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([]);\n\t\t\texpect(panel.render(80)).toEqual([]);\n\t\t});\n\n\t\tit(\"renders status line when todos exist\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([\n\t\t\t\t{ content: \"First task\", activeForm: \"First task\", status: \"in_progress\" },\n\t\t\t\t{ content: \"Second task\", activeForm: \"Second task\", status: \"pending\" },\n\t\t\t]);\n\t\t\tconst lines = panel.render(80);\n\t\t\texpect(lines.length).toBeGreaterThan(0);\n\t\t\texpect(lines[0]).toContain(\"Tasks:\");\n\t\t\texpect(lines[0]).toContain(\"done\");\n\t\t});\n\n\t\tit(\"shows correct completion count\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([\n\t\t\t\t{ content: \"Task one\", activeForm: \"Task one\", status: \"completed\" },\n\t\t\t\t{ content: \"Task two\", activeForm: \"Task two\", status: \"in_progress\" },\n\t\t\t\t{ content: \"Task three\", activeForm: \"Task three\", status: \"pending\" },\n\t\t\t\t{ content: \"Task four\", activeForm: \"Task four\", status: \"completed\" },\n\t\t\t]);\n\t\t\tconst lines = panel.render(80);\n\t\t\texpect(lines[0]).toContain(\"2/4\");\n\t\t});\n\n\t\tit(\"shows in-progress task in expanded mode\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([\n\t\t\t\t{ content: \"Working on feature\", activeForm: \"Implementing the feature\", status: \"in_progress\" },\n\t\t\t\t{ content: \"Done task\", activeForm: \"Done task\", status: \"completed\" },\n\t\t\t]);\n\t\t\tconst lines = panel.render(80);\n\t\t\t// Status line + one line per task = 3 lines\n\t\t\texpect(lines.length).toBe(3);\n\t\t\texpect(lines[0]).toContain(\"Working:\");\n\t\t\texpect(lines[0]).toContain(\"Implementing the feature\");\n\t\t});\n\n\t\tit(\"renders compact at narrow widths\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([\n\t\t\t\t{ content: \"Task one\", activeForm: \"Task one\", status: \"pending\" },\n\t\t\t\t{ content: \"Task two\", activeForm: \"Task two\", status: \"pending\" },\n\t\t\t]);\n\t\t\t// At narrow width, should only show status line\n\t\t\tconst lines = panel.render(40);\n\t\t\texpect(lines.length).toBe(1);\n\t\t\texpect(lines[0]).toContain(\"Tasks:\");\n\t\t});\n\n\t\tit(\"keeps rendered lines within width\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([\n\t\t\t\t{\n\t\t\t\t\tcontent: \"A very long task description that should be truncated at narrow widths\",\n\t\t\t\t\tactiveForm: \"A very long active form description\",\n\t\t\t\t\tstatus: \"in_progress\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcontent: \"Another long task that needs truncation when the terminal is narrow\",\n\t\t\t\t\tactiveForm: \"Another long active form text\",\n\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t},\n\t\t\t]);\n\t\t\tfor (const line of panel.render(60)) {\n\t\t\t\texpect(visibleWidth(line)).toBeLessThanOrEqual(60);\n\t\t\t}\n\t\t});\n\n\t\tit(\"handles all todo statuses correctly\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([\n\t\t\t\t{ content: \"Pending task\", activeForm: \"Pending task\", status: \"pending\" },\n\t\t\t\t{ content: \"In progress task\", activeForm: \"Working on it\", status: \"in_progress\" },\n\t\t\t\t{ content: \"Completed task\", activeForm: \"Completed task\", status: \"completed\" },\n\t\t\t]);\n\t\t\tconst lines = panel.render(80);\n\t\t\t// Status line + 3 task lines\n\t\t\texpect(lines.length).toBe(4);\n\t\t});\n\n\t\tit(\"empty todos returns empty array at any width\", () => {\n\t\t\tconst panel = new TodoListComponent();\n\t\t\tpanel.update([]);\n\t\t\t// Both narrow and wide should return empty\n\t\t\texpect(panel.render(30)).toEqual([]);\n\t\t\texpect(panel.render(100)).toEqual([]);\n\t\t});\n\t});\n});\n"]}