@@ -14,3 +14,23 @@ test('--regex', async t => {
1414 await execa ( './cli.js' , [ '--regex=\\bb.*?\\b' , '--replacement=foo' , filePath ] ) ;
1515 t . is ( fs . readFileSync ( filePath , 'utf8' ) , 'foo foo foo' ) ;
1616} ) ;
17+
18+ test ( 'newlines and tabs' , async t => {
19+ const filePath = await tempWrite ( 'a,b,c' ) ;
20+ await execa ( './cli.js' , [ '--string=,' , '--replacement=\\n' , filePath ] ) ;
21+ t . is ( fs . readFileSync ( filePath , 'utf8' ) , 'a\nb\nc' ) ;
22+
23+ const filePath2 = await tempWrite ( 'a,b,c' ) ;
24+ await execa ( './cli.js' , [ '--string=,' , '--replacement=\\t' , filePath2 ] ) ;
25+ t . is ( fs . readFileSync ( filePath2 , 'utf8' ) , 'a\tb\tc' ) ;
26+
27+ const filePath3 = await tempWrite ( 'a,b,c' ) ;
28+ await execa ( './cli.js' , [ '--string=,' , '--replacement=\\r' , filePath3 ] ) ;
29+ t . is ( fs . readFileSync ( filePath3 , 'utf8' ) , 'a\rb\rc' ) ;
30+ } ) ;
31+
32+ test ( 'multiple newlines and tabs' , async t => {
33+ const filePath = await tempWrite ( 'a,b,c' ) ;
34+ await execa ( './cli.js' , [ '--string=,' , '--replacement=\\n\\n\\t\\r' , filePath ] ) ;
35+ t . is ( fs . readFileSync ( filePath , 'utf8' ) , 'a\n\n\t\rb\n\n\t\rc' ) ;
36+ } ) ;
0 commit comments