| 1 | import { render } from "ink-testing-library"; |
| 2 | import React from "react"; |
| 3 | |
| 4 | import { ChecklistDisplay } from "./ChecklistDisplay.js"; |
| 5 | |
| 6 | describe("ChecklistDisplay", () => { |
| 7 | it("should highlight the first incomplete item", () => { |
| 8 | const content = `Task list status: |
| 9 | - [x] Completed task |
| 10 | - [ ] First incomplete task |
| 11 | - [ ] Second incomplete task`; |
| 12 | |
| 13 | const { lastFrame } = render(<ChecklistDisplay content={content} />); |
| 14 | const output = lastFrame(); |
| 15 | |
| 16 | // The output should contain the checkbox symbols and text |
| 17 | expect(output).toContain("✓"); |
| 18 | expect(output).toContain("○"); |
| 19 | expect(output).toContain("Completed task"); |
| 20 | expect(output).toContain("First incomplete task"); |
| 21 | expect(output).toContain("Second incomplete task"); |
| 22 | }); |
| 23 | |
| 24 | it("should handle empty checklist", () => { |
| 25 | const content = "Task list status:"; |
| 26 | |
| 27 | const { lastFrame } = render(<ChecklistDisplay content={content} />); |
| 28 | const output = lastFrame(); |
| 29 | |
| 30 | expect(output).toBeDefined(); |
| 31 | }); |
| 32 | |
| 33 | it("should handle all completed tasks", () => { |
| 34 | const content = `Task list status: |
| 35 | - [x] Completed task 1 |
| 36 | - [x] Completed task 2`; |
| 37 | |
| 38 | const { lastFrame } = render(<ChecklistDisplay content={content} />); |
| 39 | const output = lastFrame(); |
| 40 | |
| 41 | expect(output).toContain("✓"); |
| 42 | expect(output).toContain("Completed task 1"); |
| 43 | expect(output).toContain("Completed task 2"); |
| 44 | }); |
| 45 | |
| 46 | it("should handle mixed content with headers", () => { |
| 47 | const content = `Task list status: |
| 48 | ## Important Tasks |
| 49 | - [x] Done task |
| 50 | - [ ] Todo task |
| 51 | |
| 52 | ## Other Tasks |
| 53 | - [ ] Another todo`; |
| 54 | |
| 55 | const { lastFrame } = render(<ChecklistDisplay content={content} />); |
| 56 | const output = lastFrame(); |
| 57 | |
| 58 | expect(output).toContain("Important Tasks"); |
| 59 | expect(output).toContain("Other Tasks"); |
| 60 | expect(output).toContain("✓"); |
| 61 | expect(output).toContain("○"); |
| 62 | }); |
| 63 | }); |