@@ -312,9 +312,12 @@ fn validate_title(
312
312
return ;
313
313
} ;
314
314
315
- // TODO: support fixer
316
315
if first_word == un_prefixed_name {
317
- Message :: DuplicatePrefix . diagnostic ( ctx, span) ;
316
+ let ( error, help) = Message :: DuplicatePrefix . detail ( ) ;
317
+ ctx. diagnostic_with_fix ( valid_title_diagnostic ( error, help, span) , |fixer| {
318
+ let replaced_title = title[ first_word. len ( ) ..] . trim ( ) . to_string ( ) ;
319
+ fixer. replace ( span. shrink_left ( 1 ) . shrink_right ( 1 ) , replaced_title)
320
+ } ) ;
318
321
return ;
319
322
}
320
323
@@ -967,6 +970,55 @@ fn test() {
967
970
})
968
971
" ,
969
972
) ,
973
+ ( "describe('describe foo', function () {})" , "describe('foo', function () {})" ) ,
974
+ ( "fdescribe('describe foo', function () {})" , "fdescribe('foo', function () {})" ) ,
975
+ ( "xdescribe('describe foo', function () {})" , "xdescribe('foo', function () {})" ) ,
976
+ ( "describe('describe foo', function () {})" , "describe('foo', function () {})" ) ,
977
+ ( "fdescribe(`describe foo`, function () {})" , "fdescribe(`foo`, function () {})" ) ,
978
+ ( "test('test foo', function () {})" , "test('foo', function () {})" ) ,
979
+ ( "xtest('test foo', function () {})" , "xtest('foo', function () {})" ) ,
980
+ ( "test(`test foo`, function () {})" , "test(`foo`, function () {})" ) ,
981
+ ( "test(`test foo test`, function () {})" , "test(`foo test`, function () {})" ) ,
982
+ ( "it('it foo', function () {})" , "it('foo', function () {})" ) ,
983
+ ( "fit('it foo', function () {})" , "fit('foo', function () {})" ) ,
984
+ ( "xit('it foo', function () {})" , "xit('foo', function () {})" ) ,
985
+ ( "it('it foos it correctly', function () {})" , "it('foos it correctly', function () {})" ) ,
986
+ (
987
+ "
988
+ describe('describe foo', () => {
989
+ it('bar', () => {})
990
+ })
991
+ " ,
992
+ "
993
+ describe('foo', () => {
994
+ it('bar', () => {})
995
+ })
996
+ " ,
997
+ ) ,
998
+ (
999
+ "
1000
+ describe('describe foo', () => {
1001
+ it('describes things correctly', () => {})
1002
+ })
1003
+ " ,
1004
+ "
1005
+ describe('foo', () => {
1006
+ it('describes things correctly', () => {})
1007
+ })
1008
+ " ,
1009
+ ) ,
1010
+ (
1011
+ "
1012
+ describe('foo', () => {
1013
+ it('it bar', () => {})
1014
+ })
1015
+ " ,
1016
+ "
1017
+ describe('foo', () => {
1018
+ it('bar', () => {})
1019
+ })
1020
+ " ,
1021
+ ) ,
970
1022
] ;
971
1023
972
1024
Tester :: new ( ValidTitle :: NAME , pass, fail)
0 commit comments