1- import path from ' path'
2- import { exec } from ' child_process'
3- import { promisify } from ' util'
4- import { init } from ' ./../src/index'
5- import { shouldHideMessage } from ' ../src/utils/misc' ;
1+ import path from " path" ;
2+ import { exec } from " child_process" ;
3+ import { promisify } from " util" ;
4+ import { init } from " ./../src/index" ;
5+ import { shouldHideMessage } from " ../src/utils/misc" ;
66
7- describe ( ' Integration test' , ( ) => {
8- const pkgPath = path . resolve ( ' __tests__/fixtures/pkg' ) ;
7+ describe ( " Integration test" , ( ) => {
8+ const pkgPath = path . resolve ( " __tests__/fixtures/pkg" ) ;
99
10- const consolelog = global . console . log
10+ const consolelog = global . console . log ;
1111
12- it ( 'prints everything' , async ( ) => {
13-
14- let log = ''
12+ it ( "prints everything" , async ( ) => {
13+ let log = "" ;
1514 console . log = jest . fn ( ) . mockImplementation ( ( str1 , str2 ) => {
16- log += str1 + str2
17- } )
15+ log += str1 + str2 ;
16+ } ) ;
1817
19- await init ( pkgPath , false )
18+ await init ( pkgPath , false ) ;
2019
21- console . log = consolelog
20+ console . log = consolelog ;
2221 const content = [
23- ' Thanks for installing pkg' ,
24- ' Please consider donating to help us maintain this package.' ,
25- ' GitHub' ,
26- ' https://github.com/users/Jack/sponsorship' ,
27- ' Patreon' ,
28- ' https://patreon.com/Jack' ,
29- ' Open Collective'
30- ]
22+ " Thanks for installing pkg" ,
23+ " Please consider donating to help us maintain this package." ,
24+ " GitHub" ,
25+ " https://github.com/users/Jack/sponsorship" ,
26+ " Patreon" ,
27+ " https://patreon.com/Jack" ,
28+ " Open Collective"
29+ ] ;
3130
3231 content . forEach ( sentence => {
33- expect ( log . includes ( sentence ) ) . toBe ( true )
34- } )
35- } )
36-
32+ expect ( log . includes ( sentence ) ) . toBe ( true ) ;
33+ } ) ;
34+ } ) ;
35+
36+ it ( "returns expected result on postinstall script" , async ( ) => {
37+ process . env . GITHUB_SPONSORS_FORCE = true ;
38+ const { stdout : rawStdout } = await promisify ( exec ) ( "npm run postinstall" , {
39+ cwd : pkgPath ,
40+ env : process . env
41+ } ) ;
42+ const stdout = rawStdout . toString ( "utf8" ) ;
3743
38- it ( 'returns expected result on postinstall script' , async ( ) => {
39- process . env . GITHUB_SPONSORS_FORCE = true
40- const { stdout : rawStdout } = await promisify ( exec ) ( 'npm run postinstall' , { cwd : pkgPath , env : process . env } )
41- const stdout = rawStdout . toString ( 'utf8' )
42-
4344 const content = [
44- ' Thanks for installing pkg' ,
45- ' Please consider donating to help us maintain this package.'
46- ]
45+ " Thanks for installing pkg" ,
46+ " Please consider donating to help us maintain this package."
47+ ] ;
4748 content . forEach ( sentence => {
48- expect ( stdout . includes ( sentence ) ) . toBe ( true )
49- } )
50- } )
51-
52-
53- } )
49+ expect ( stdout . includes ( sentence ) ) . toBe ( true ) ;
50+ } ) ;
51+ } ) ;
52+ } ) ;
0 commit comments