| 183 | } |
| 184 | |
| 185 | func TestToMermaid(t *testing.T) { |
| 186 | tasks := []*model.Task{ |
| 187 | { |
| 188 | ID: "T1", |
| 189 | Title: "Task 1", |
| 190 | Status: model.StatusCompleted, |
| 191 | Dependencies: []string{}, |
| 192 | }, |
| 193 | { |
| 194 | ID: "T2", |
| 195 | Title: "Task 2", |
| 196 | Status: model.StatusPending, |
| 197 | Dependencies: []string{"T1"}, |
| 198 | }, |
| 199 | } |
| 200 | |
| 201 | g := NewGraph(tasks) |
| 202 | output := g.ToMermaid("T2") |
| 203 | |
| 204 | if !strings.Contains(output, "graph TD") { |
| 205 | t.Error("Expected mermaid output to contain 'graph TD'") |
| 206 | } |
| 207 | |
| 208 | if !strings.Contains(output, "T1") { |
| 209 | t.Error("Expected mermaid output to contain T1") |
| 210 | } |
| 211 | |
| 212 | if !strings.Contains(output, "T2") { |
| 213 | t.Error("Expected mermaid output to contain T2") |
| 214 | } |
| 215 | |
| 216 | if !strings.Contains(output, "T1 --> T2") { |
| 217 | t.Error("Expected mermaid output to contain edge T1 --> T2") |
| 218 | } |
| 219 | |
| 220 | if !strings.Contains(output, ":::focus") { |
| 221 | t.Error("Expected mermaid output to highlight focus task") |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | func TestToDot(t *testing.T) { |
| 226 | tasks := []*model.Task{ |