@@ -99,5 +99,63 @@ module('Unit | patch-testem-output', function () {
9999 'Exam Partition 2 - Browser Id 1 - test_module | test_name' ,
100100 ) ;
101101 } ) ;
102+
103+ test ( 'does not add partition number again when the test name already contains it' , function ( assert ) {
104+ assert . deepEqual (
105+ TestemOutput . updateTestName (
106+ new Map ( ) . set ( 'split' , 2 ) . set ( 'partition' , 2 ) ,
107+ 'Exam Partition 2 - test_module | test_name' ,
108+ ) ,
109+ 'Exam Partition 2 - test_module | test_name' ,
110+ ) ;
111+ } ) ;
112+
113+ test ( 'does not add browser number again when the test name already contains it' , function ( assert ) {
114+ assert . deepEqual (
115+ TestemOutput . updateTestName (
116+ new Map ( ) . set ( 'loadBalance' , 2 ) . set ( 'browser' , 1 ) ,
117+ 'Browser Id 1 - test_module | test_name' ,
118+ ) ,
119+ 'Browser Id 1 - test_module | test_name' ,
120+ ) ;
121+ } ) ;
122+ } ) ;
123+
124+ module ( 'patchTestemOutput' , function ( hooks ) {
125+ let originalTestem ;
126+ let handlers ;
127+
128+ hooks . beforeEach ( function ( ) {
129+ originalTestem = window . Testem ;
130+ handlers = new Map ( ) ;
131+ window . Testem = {
132+ on ( event , callback ) {
133+ handlers . set ( event , callback ) ;
134+ } ,
135+ } ;
136+ } ) ;
137+
138+ hooks . afterEach ( function ( ) {
139+ window . Testem = originalTestem ;
140+ } ) ;
141+
142+ test ( 'updates the test name when a test starts and when it completes' , function ( assert ) {
143+ TestemOutput . patchTestemOutput ( new Map ( ) . set ( 'split' , 2 ) ) ;
144+
145+ const test = { name : 'test_module | test_name' } ;
146+ handlers . get ( 'tests-start' ) ( test ) ;
147+ assert . deepEqual ( test . name , 'Exam Partition 1 - test_module | test_name' ) ;
148+
149+ handlers . get ( 'test-result' ) ( test ) ;
150+ assert . deepEqual ( test . name , 'Exam Partition 1 - test_module | test_name' ) ;
151+ } ) ;
152+
153+ test ( 'handles tests-start events without a test name' , function ( assert ) {
154+ TestemOutput . patchTestemOutput ( new Map ( ) . set ( 'split' , 2 ) ) ;
155+
156+ const test = { } ;
157+ handlers . get ( 'tests-start' ) ( test ) ;
158+ assert . deepEqual ( test . name , undefined ) ;
159+ } ) ;
102160 } ) ;
103161} ) ;
0 commit comments