MCPcopy Create free account
hub / github.com/cli/cli / TestIssueView_tty_Comments

Function TestIssueView_tty_Comments

pkg/cmd/issue/view/view_test.go:399–470  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

397}
398
399func TestIssueView_tty_Comments(t *testing.T) {
400 tests := map[string]struct {
401 cli string
402 httpStubs func(*httpmock.Registry)
403 expectedOutputs []string
404 wantsErr bool
405 }{
406 "without comments flag": {
407 cli: "123",
408 httpStubs: func(r *httpmock.Registry) {
409 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
410 mockEmptyV2ProjectItems(t, r)
411 },
412 expectedOutputs: []string{
413 `some title OWNER/REPO#123`,
414 `some body`,
415 `———————— Not showing 5 comments ————————`,
416 `marseilles \(Collaborator\) • Jan 1, 2020 • Newest comment`,
417 `Comment 5`,
418 `Use --comments to view the full conversation`,
419 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
420 },
421 },
422 "with comments flag": {
423 cli: "123 --comments",
424 httpStubs: func(r *httpmock.Registry) {
425 r.Register(httpmock.GraphQL(`query IssueByNumber\b`), httpmock.FileResponse("./fixtures/issueView_previewSingleComment.json"))
426 r.Register(httpmock.GraphQL(`query CommentsForIssue\b`), httpmock.FileResponse("./fixtures/issueView_previewFullComments.json"))
427 mockEmptyV2ProjectItems(t, r)
428 },
429 expectedOutputs: []string{
430 `some title OWNER/REPO#123`,
431 `some body`,
432 `monalisa • Jan 1, 2020 • Edited`,
433 `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}`,
434 `Comment 1`,
435 `johnnytest \(Contributor\) • Jan 1, 2020`,
436 `Comment 2`,
437 `elvisp \(Member\) • Jan 1, 2020`,
438 `Comment 3`,
439 `loislane \(Owner\) • Jan 1, 2020`,
440 `Comment 4`,
441 `sam-spam • This comment has been marked as spam`,
442 `marseilles \(Collaborator\) • Jan 1, 2020 • Newest comment`,
443 `Comment 5`,
444 `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`,
445 },
446 },
447 "with invalid comments flag": {
448 cli: "123 --comments 3",
449 wantsErr: true,
450 },
451 }
452 for name, tc := range tests {
453 t.Run(name, func(t *testing.T) {
454 http := &httpmock.Registry{}
455 defer http.Verify(t)
456 if tc.httpStubs != nil {

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
GraphQLFunction · 0.92
FileResponseFunction · 0.92
ExpectLinesFunction · 0.92
mockEmptyV2ProjectItemsFunction · 0.85
EqualMethod · 0.80
StderrMethod · 0.80
runCommandFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
RegisterMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected