(t *testing.T)
| 204 | } |
| 205 | |
| 206 | func TestSubmenus(t *testing.T) { |
| 207 | is := is.New(t) |
| 208 | |
| 209 | p := &Plugin{} |
| 210 | items, err := p.parseOutput(context.Background(), "text.txt", strings.NewReader(strings.TrimSpace(` |
| 211 | cycle1 |
| 212 | cycle2 |
| 213 | cycle3 |
| 214 | --- |
| 215 | parent1 |
| 216 | --child1 |
| 217 | --child2 |
| 218 | --child3 |
| 219 | ----subchild1 |
| 220 | ----subchild2 |
| 221 | ------subsubchild1 |
| 222 | --child4 |
| 223 | parent2 |
| 224 | --child1 |
| 225 | --child2 |
| 226 | --child3 |
| 227 | parent3 |
| 228 | `))) |
| 229 | is.NoErr(err) |
| 230 | is.Equal(len(items.ExpandedItems), 3) // 3 parent items |
| 231 | is.Equal(items.ExpandedItems[0].Text, "parent1") |
| 232 | is.Equal(len(items.ExpandedItems[0].Items), 4) |
| 233 | is.Equal(items.ExpandedItems[0].Items[0].Text, "child1") |
| 234 | is.Equal(items.ExpandedItems[0].Items[1].Text, "child2") |
| 235 | is.Equal(items.ExpandedItems[0].Items[2].Text, "child3") |
| 236 | is.Equal(len(items.ExpandedItems[0].Items[2].Items), 2) |
| 237 | is.Equal(items.ExpandedItems[0].Items[2].Items[0].Text, "subchild1") |
| 238 | is.Equal(items.ExpandedItems[0].Items[2].Items[1].Text, "subchild2") |
| 239 | is.Equal(items.ExpandedItems[0].Items[3].Text, "child4") |
| 240 | is.Equal(items.ExpandedItems[1].Text, "parent2") |
| 241 | is.Equal(len(items.ExpandedItems[1].Items), 3) |
| 242 | is.Equal(items.ExpandedItems[1].Items[0].Text, "child1") |
| 243 | is.Equal(items.ExpandedItems[1].Items[1].Text, "child2") |
| 244 | is.Equal(items.ExpandedItems[1].Items[2].Text, "child3") |
| 245 | is.Equal(items.ExpandedItems[2].Text, "parent3") |
| 246 | is.Equal(len(items.ExpandedItems[2].Items), 0) |
| 247 | } |
| 248 | |
| 249 | func TestOnErr(t *testing.T) { |
| 250 | is := is.New(t) |
nothing calls this directly
no test coverage detected