MCPcopy
hub / github.com/cli/cli / TestIssueView_tty_Comments

Function TestIssueView_tty_Comments

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

Source from the content-addressed store, hash-verified

385}
386
387func 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 {

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
RegisterMethod · 0.45
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected