@@ -10,6 +10,7 @@ var makeRunReporter = helpers.createRunReporterFunction;
1010
1111var EVENT_RUN_BEGIN = events . EVENT_RUN_BEGIN ;
1212var EVENT_RUN_END = events . EVENT_RUN_END ;
13+ var EVENT_SUITE_BEGIN = events . EVENT_SUITE_BEGIN ;
1314var EVENT_TEST_END = events . EVENT_TEST_END ;
1415var EVENT_TEST_FAIL = events . EVENT_TEST_FAIL ;
1516var EVENT_TEST_PASS = events . EVENT_TEST_PASS ;
@@ -23,6 +24,7 @@ describe("TAP reporter", function () {
2324
2425 function createTest ( ) {
2526 return {
27+ title : expectedTitle ,
2628 fullTitle : function ( ) {
2729 return expectedTitle ;
2830 } ,
@@ -529,4 +531,85 @@ describe("TAP reporter", function () {
529531 } ) ;
530532 } ) ;
531533 } ) ;
534+
535+ describe ( "suite hierarchy" , function ( ) {
536+ var options = {
537+ reporterOptions : {
538+ tapVersion : "12" ,
539+ } ,
540+ } ;
541+
542+ describe ( "on 'suite' event" , function ( ) {
543+ var stdout ;
544+ var expectedSuiteTitle = "My Suite" ;
545+
546+ before ( async function ( ) {
547+ var suite = { root : false , title : expectedSuiteTitle } ;
548+ var runner = createMockRunner (
549+ "suite" ,
550+ EVENT_SUITE_BEGIN ,
551+ null ,
552+ null ,
553+ suite ,
554+ ) ;
555+ runner . suite = "" ;
556+ ( { stdout } = await runReporter ( { } , runner , options ) ) ;
557+ } ) ;
558+
559+ it ( "should write a comment with the suite title" , function ( ) {
560+ expect ( stdout [ 0 ] , "to equal" , "# " + expectedSuiteTitle + "\n" ) ;
561+ } ) ;
562+ } ) ;
563+
564+ describe ( "on 'suite' event with root suite" , function ( ) {
565+ var stdout ;
566+
567+ before ( async function ( ) {
568+ var suite = { root : true , title : "" } ;
569+ var runner = createMockRunner (
570+ "suite" ,
571+ EVENT_SUITE_BEGIN ,
572+ null ,
573+ null ,
574+ suite ,
575+ ) ;
576+ runner . suite = "" ;
577+ ( { stdout } = await runReporter ( { } , runner , options ) ) ;
578+ } ) ;
579+
580+ it ( "should not write a comment for the root suite" , function ( ) {
581+ expect ( stdout , "to be empty" ) ;
582+ } ) ;
583+ } ) ;
584+
585+ describe ( "on 'pass' event with suite context" , function ( ) {
586+ var stdout ;
587+ var testTitle = "should work" ;
588+
589+ before ( async function ( ) {
590+ var test = {
591+ title : testTitle ,
592+ fullTitle : function ( ) {
593+ return "My Suite should work" ;
594+ } ,
595+ slow : noop ,
596+ } ;
597+ var runner = createMockRunner (
598+ "start test" ,
599+ EVENT_TEST_END ,
600+ EVENT_TEST_PASS ,
601+ null ,
602+ test ,
603+ ) ;
604+ runner . suite = "" ;
605+ ( { stdout } = await runReporter ( { } , runner , options ) ) ;
606+ } ) ;
607+
608+ it ( "should use test title not fullTitle in output" , function ( ) {
609+ var expectedMessage =
610+ "ok " + countAfterTestEnd + " " + testTitle + "\n" ;
611+ expect ( stdout [ 0 ] , "to equal" , expectedMessage ) ;
612+ } ) ;
613+ } ) ;
614+ } ) ;
532615} ) ;
0 commit comments