(t *testing.T)
| 385 | } |
| 386 | |
| 387 | func TestIssueView_tty_Comments(t *testing.T) { |
| 388 | tests := map[string]struct { |
| 389 | cli string |
| 390 | httpStubs func(*httpmock.Registry) |
| 391 | expectedOutputs []string |
| 392 | wantsErr bool |
| 393 | }{ |
| 394 | "without comments flag": { |
| 395 | cli: "123", |
| 396 | httpStubs: func(r *httpmock.Registry) { |
| 397 | r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json")) |
| 398 | mockEmptyV2ProjectItems(t, r) |
| 399 | }, |
| 400 | expectedOutputs: []string{ |
| 401 | `some title OWNER/REPO#123`, |
| 402 | `some body`, |
| 403 | `———————— Not showing 5 comments ————————`, |
| 404 | `marseilles \(Collaborator\) • Jan 1, 2020 • Newest comment`, |
| 405 | `Comment 5`, |
| 406 | `Use --comments to view the full conversation`, |
| 407 | `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, |
| 408 | }, |
| 409 | }, |
| 410 | "with comments flag": { |
| 411 | cli: "123 --comments", |
| 412 | httpStubs: func(r *httpmock.Registry) { |
| 413 | r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json")) |
| 414 | r.Register(httpmock.GraphQL(`query CommentsForIssue\b`), httpmock.FileResponse("./fixtures/issueView_previewFullComments.json")) |
| 415 | mockEmptyV2ProjectItems(t, r) |
| 416 | }, |
| 417 | expectedOutputs: []string{ |
| 418 | `some title OWNER/REPO#123`, |
| 419 | `some body`, |
| 420 | `monalisa • Jan 1, 2020 • Edited`, |
| 421 | `1 \x{1f615} • 2 \x{1f440} • 3 \x{2764}\x{fe0f} • 4 \x{1f389} • 5 \x{1f604} • 6 \x{1f680} • 7 \x{1f44e} • 8 \x{1f44d}`, |
| 422 | `Comment 1`, |
| 423 | `johnnytest \(Contributor\) • Jan 1, 2020`, |
| 424 | `Comment 2`, |
| 425 | `elvisp \(Member\) • Jan 1, 2020`, |
| 426 | `Comment 3`, |
| 427 | `loislane \(Owner\) • Jan 1, 2020`, |
| 428 | `Comment 4`, |
| 429 | `sam-spam • This comment has been marked as spam`, |
| 430 | `marseilles \(Collaborator\) • Jan 1, 2020 • Newest comment`, |
| 431 | `Comment 5`, |
| 432 | `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, |
| 433 | }, |
| 434 | }, |
| 435 | "with invalid comments flag": { |
| 436 | cli: "123 --comments 3", |
| 437 | wantsErr: true, |
| 438 | }, |
| 439 | } |
| 440 | for name, tc := range tests { |
| 441 | t.Run(name, func(t *testing.T) { |
| 442 | http := &httpmock.Registry{} |
| 443 | defer http.Verify(t) |
| 444 | if tc.httpStubs != nil { |
nothing calls this directly
no test coverage detected