1- /* eslint-disable vitest/no-disabled-tests */
1+ /* eslint-disable @ vitest/no-disabled-tests */
22/* eslint-disable no-console */
33import type { Command , Config } from '@oclif/core' ;
44import type { Response } from 'simple-git' ;
@@ -89,22 +89,27 @@ describe('#createGHA', () => {
8989
9090 it ( 'should run GHA creation workflow and generate valid workflow file' , async ( ) => {
9191 expect . assertions ( 6 ) ;
92+
9293 const fileName = `rdme-${ cmd } ` ;
9394 prompts . inject ( [ true , 'some-branch' , fileName ] ) ;
9495
9596 const res = await oclifConfig . runHook ( 'createGHA' , { command : CurrentCommand , parsedOpts : opts , result : '' } ) ;
97+
9698 expect ( res . successes [ 0 ] . result ) . toMatchSnapshot ( ) ;
9799
98100 expect ( yamlOutput ) . toBeValidSchema ( ghaWorkflowSchema ) ;
99101 expect ( yamlOutput ) . toMatchSnapshot ( ) ;
100102 expect ( fs . writeFileSync ) . toHaveBeenCalledWith ( getGHAFileName ( fileName ) , expect . any ( String ) ) ;
101103 expect ( console . info ) . toHaveBeenCalledTimes ( 1 ) ;
104+
102105 const output = getCommandOutput ( ) ;
106+
103107 expect ( output ) . toMatch ( "Looks like you're running this command in a GitHub Repository!" ) ;
104108 } ) ;
105109
106110 it ( 'should run GHA creation workflow with `--github` flag and messy file name and generate valid workflow file' , async ( ) => {
107111 expect . assertions ( 4 ) ;
112+
108113 const fileName = `rdme-${ cmd } with GitHub flag` ;
109114 prompts . inject ( [ 'another-branch' , fileName ] ) ;
110115
@@ -113,6 +118,7 @@ describe('#createGHA', () => {
113118 parsedOpts : { ...opts , github : true } ,
114119 result : '' ,
115120 } ) ;
121+
116122 expect ( res . successes [ 0 ] . result ) . toMatchSnapshot ( ) ;
117123
118124 expect ( yamlOutput ) . toBeValidSchema ( ghaWorkflowSchema ) ;
@@ -123,6 +129,7 @@ describe('#createGHA', () => {
123129 // skipping because these mocks aren't playing nicely with oclif
124130 it . skip ( 'should create workflow directory if it does not exist' , async ( ) => {
125131 expect . assertions ( 3 ) ;
132+
126133 const repoRoot = '__tests__/__fixtures__' ;
127134
128135 git . revparse = vi . fn ( ( ) => {
@@ -137,7 +144,8 @@ describe('#createGHA', () => {
137144 } ) ;
138145
139146 const res = await oclifConfig . runHook ( 'createGHA' , { command : CurrentCommand , parsedOpts : opts , result : '' } ) ;
140- expect ( res . successes [ 0 ] . result ) . toBeTruthy ( ) ;
147+
148+ expect ( res . successes [ 0 ] . result ) . toBe ( true ) ;
141149
142150 expect ( fs . mkdirSync ) . toHaveBeenCalledWith ( '.github/workflows' , { recursive : true } ) ;
143151 expect ( fs . writeFileSync ) . toHaveBeenCalledWith ( getGHAFileName ( fileName ) , expect . any ( String ) ) ;
@@ -157,6 +165,7 @@ describe('#createGHA', () => {
157165
158166 it ( 'should set config and exit if user does not want to set up GHA' , async ( ) => {
159167 expect . assertions ( 2 ) ;
168+
160169 prompts . inject ( [ false ] ) ;
161170
162171 const repoRoot = process . cwd ( ) ;
@@ -166,6 +175,7 @@ describe('#createGHA', () => {
166175 } ) ;
167176
168177 const res = await oclifConfig . runHook ( 'createGHA' , { command : CurrentCommand , parsedOpts : opts , result : '' } ) ;
178+
169179 expect ( res . failures [ 0 ] . error ) . toStrictEqual (
170180 new Error (
171181 'GitHub Actions workflow creation cancelled. If you ever change your mind, you can run this command again with the `--github` flag.' ,
@@ -239,9 +249,11 @@ describe('#createGHA', () => {
239249 parsedOpts : opts ,
240250 result : 'success!' ,
241251 } ) ;
252+
242253 expect ( res . successes [ 0 ] . result ) . toBe ( 'success!' ) ;
243254 // asserts that git commands aren't run in CI
244255 expect ( git . checkIsRepo ) . not . toHaveBeenCalled ( ) ;
256+
245257 delete process . env . TEST_RDME_CI ;
246258 } ) ;
247259
@@ -252,9 +264,11 @@ describe('#createGHA', () => {
252264 parsedOpts : opts ,
253265 result : 'success!' ,
254266 } ) ;
267+
255268 expect ( res . successes [ 0 ] . result ) . toBe ( 'success!' ) ;
256269 // asserts that git commands aren't run in CI
257270 expect ( git . checkIsRepo ) . not . toHaveBeenCalled ( ) ;
271+
258272 delete process . env . TEST_RDME_NPM_SCRIPT ;
259273 } ) ;
260274
0 commit comments