@@ -4,51 +4,22 @@ import {random_filename, write_file, remove_file, read_file, __dirname} from "./
4
4
import { apply_patch } from '../lib/runner.js'
5
5
6
6
beforeEach ( async ( context ) => {
7
- context . base_path = random_filename ( )
7
+ context . base_url = 'https://raw.githubusercontent.com/pkgjs/patch-my-code-of-conduct/cd136b70909ad4c14d738d0399e09559ca2a3ecd/template/base.md'
8
+ context . template_url = 'https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md' ;
8
9
context . patch_path = random_filename ( )
9
10
context . output_path = random_filename ( )
10
11
11
- await write_file ( context . base_path )
12
12
await write_file ( context . patch_path )
13
13
await write_file ( context . output_path )
14
14
15
15
return async ( ) => {
16
- await remove_file ( context . base_path )
17
16
await remove_file ( context . patch_path )
18
17
await remove_file ( context . output_path )
19
18
}
20
19
} )
21
20
22
21
test ( 'should add base as prefix' , async ( context ) => {
23
- await write_file ( context . base_path , 'this is a prefix' )
24
- await apply_patch ( context . base_path , context . patch_path , context . output_path )
22
+ await apply_patch ( context . base_url , context . template_url , context . patch_path , context . output_path )
25
23
const output = await read_file ( context . output_path )
26
- assert . isTrue ( output . startsWith ( 'this is a prefix\n' ) )
27
- } )
28
-
29
- test ( 'should apply the patch' , async ( context ) => {
30
- const base_path = path . join ( __dirname , '../test/fixture/base.md' ) ;
31
- const patch_path = path . join ( __dirname , '../test/fixture/patch.txt' ) ;
32
- const output_path = path . join ( __dirname , '../test/fixture/output.md' ) ;
33
-
34
- await remove_file ( output_path ) ;
35
-
36
- const title = `CHANGED THE TITLE OF COC`
37
- const patch_text = `--- /dev/null 2022-11-11 18:00:48
38
- +++ output.md 2022-11-11 18:00:32
39
- @@ -43,7 +43,7 @@
40
-
41
- ---
42
-
43
- -# ${ title }
44
- +# Contributor Covenant Code of Conduct
45
-
46
- ## Our Pledge
47
-
48
- `
49
- await write_file ( patch_path , patch_text )
50
-
51
- await apply_patch ( base_path , patch_path , output_path )
52
- const output = await read_file ( output_path )
53
- assert . isTrue ( output . includes ( title ) )
24
+ assert . isTrue ( output . startsWith ( 'This is the beginning of our Code of Conduct.\n' ) )
54
25
} )
0 commit comments