1- import { beforeEach , describe , expect , it , jest } from '@jest/globals' ;
1+ import { describe , expect , it , jest } from '@jest/globals' ;
22import * as fs from 'fs' ;
3- import * as os from 'os' ;
43import * as path from 'path' ;
54
65import * as context from '../src/context' ;
@@ -166,30 +165,6 @@ describe('asyncForEach', () => {
166165 } ) ;
167166} ) ;
168167
169- describe ( 'setOutput' , ( ) => {
170- beforeEach ( ( ) => {
171- process . stdout . write = jest . fn ( ) as typeof process . stdout . write ;
172- } ) ;
173-
174- // eslint-disable-next-line jest/expect-expect
175- it ( 'setOutput produces the correct command' , ( ) => {
176- context . setOutput ( 'some output' , 'some value' ) ;
177- assertWriteCalls ( [ `::set-output name=some output::some value${ os . EOL } ` ] ) ;
178- } ) ;
179-
180- // eslint-disable-next-line jest/expect-expect
181- it ( 'setOutput handles bools' , ( ) => {
182- context . setOutput ( 'some output' , false ) ;
183- assertWriteCalls ( [ `::set-output name=some output::false${ os . EOL } ` ] ) ;
184- } ) ;
185-
186- // eslint-disable-next-line jest/expect-expect
187- it ( 'setOutput handles numbers' , ( ) => {
188- context . setOutput ( 'some output' , 1.01 ) ;
189- assertWriteCalls ( [ `::set-output name=some output::1.01${ os . EOL } ` ] ) ;
190- } ) ;
191- } ) ;
192-
193168// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
194169function getInputName ( name : string ) : string {
195170 return `INPUT_${ name . replace ( / / g, '_' ) . toUpperCase ( ) } ` ;
@@ -198,11 +173,3 @@ function getInputName(name: string): string {
198173function setInput ( name : string , value : string ) : void {
199174 process . env [ getInputName ( name ) ] = value ;
200175}
201-
202- // Assert that process.stdout.write calls called only with the given arguments.
203- function assertWriteCalls ( calls : string [ ] ) : void {
204- expect ( process . stdout . write ) . toHaveBeenCalledTimes ( calls . length ) ;
205- for ( let i = 0 ; i < calls . length ; i ++ ) {
206- expect ( process . stdout . write ) . toHaveBeenNthCalledWith ( i + 1 , calls [ i ] ) ;
207- }
208- }
0 commit comments