@@ -11,7 +11,12 @@ import nock from "nock";
1111import * as sinon from "sinon" ;
1212
1313import { ActionState , StateFeature } from "./action-common" ;
14- import { ActionsEnv , ActionsEnvVars , getActionVersion } from "./actions-util" ;
14+ import {
15+ ActionsEnv ,
16+ ActionsEnvVars ,
17+ getActionsEnv ,
18+ getActionVersion ,
19+ } from "./actions-util" ;
1520import { AnalysisKind } from "./analyses" ;
1621import * as apiClient from "./api-client" ;
1722import { GitHubApiDetails } from "./api-client" ;
@@ -190,7 +195,7 @@ export function getTestActionsEnv(): ActionsEnv {
190195}
191196
192197/** For testing purposes, we make all available state features accessible in `TestEnv`. */
193- type AllState = [ "Logger" , "Env" , "FeatureFlags" ] ;
198+ type AllState = [ "Logger" , "Env" , "Actions" , " FeatureFlags"] ;
194199
195200/**
196201 * Wraps a function that accepts an `ActionState` for testing in different environments.
@@ -218,6 +223,7 @@ export class TestEnv<
218223 : {
219224 logger : new RecordingLogger ( ) ,
220225 env : getTestEnv ( ) ,
226+ actions : getActionsEnv ( ) ,
221227 features : createFeatures ( [ ] ) ,
222228 } ;
223229 }
@@ -256,6 +262,12 @@ export class TestEnv<
256262 return result ;
257263 }
258264
265+ public withActions ( actions : ActionsEnv ) : TestEnv < Args , R , Fs > {
266+ const result = this . clone ( ) ;
267+ result . state . actions = actions ;
268+ return result ;
269+ }
270+
259271 call ( ) : R {
260272 if ( ! this . args ) {
261273 throw new Error ( "Trying to call function in TestEnv without arguments." ) ;
0 commit comments