@@ -411,6 +411,66 @@ func TestPRView_preview(t *testing.T) {
411411 }
412412}
413413
414+ func TestPRView_previewClosedState (t * testing.T ) {
415+ initBlankContext ("OWNER/REPO" , "master" )
416+ http := initFakeHTTP ()
417+ http .StubRepoResponse ("OWNER" , "REPO" )
418+
419+ jsonFile , _ := os .Open ("../test/fixtures/prViewPreviewClosedState.json" )
420+ defer jsonFile .Close ()
421+ http .StubResponse (200 , jsonFile )
422+
423+ output , err := RunCommand (prViewCmd , "pr view -p 12" )
424+ if err != nil {
425+ t .Errorf ("error running command `pr view`: %v" , err )
426+ }
427+
428+ eq (t , output .Stderr (), "" )
429+
430+ expectedLines := []* regexp.Regexp {
431+ regexp .MustCompile (`Blueberries are from a fork` ),
432+ regexp .MustCompile (`CLOSED • nobody wants to merge 12 commits into master from blueberries` ),
433+ regexp .MustCompile (`blueberries taste good` ),
434+ regexp .MustCompile (`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12` ),
435+ }
436+ for _ , r := range expectedLines {
437+ if ! r .MatchString (output .String ()) {
438+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , r , output )
439+ return
440+ }
441+ }
442+ }
443+
444+ func TestPRView_previewMergedState (t * testing.T ) {
445+ initBlankContext ("OWNER/REPO" , "master" )
446+ http := initFakeHTTP ()
447+ http .StubRepoResponse ("OWNER" , "REPO" )
448+
449+ jsonFile , _ := os .Open ("../test/fixtures/prViewPreviewMergedState.json" )
450+ defer jsonFile .Close ()
451+ http .StubResponse (200 , jsonFile )
452+
453+ output , err := RunCommand (prViewCmd , "pr view -p 12" )
454+ if err != nil {
455+ t .Errorf ("error running command `pr view`: %v" , err )
456+ }
457+
458+ eq (t , output .Stderr (), "" )
459+
460+ expectedLines := []* regexp.Regexp {
461+ regexp .MustCompile (`Blueberries are from a fork` ),
462+ regexp .MustCompile (`MERGED • nobody wants to merge 12 commits into master from blueberries` ),
463+ regexp .MustCompile (`blueberries taste good` ),
464+ regexp .MustCompile (`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12` ),
465+ }
466+ for _ , r := range expectedLines {
467+ if ! r .MatchString (output .String ()) {
468+ t .Errorf ("output did not match regexp /%s/\n > output\n %s\n " , r , output )
469+ return
470+ }
471+ }
472+ }
473+
414474func TestPRView_previewCurrentBranch (t * testing.T ) {
415475 initBlankContext ("OWNER/REPO" , "blueberries" )
416476 http := initFakeHTTP ()
0 commit comments