File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,24 @@ import { getErrorMessage } from "./util";
1919
2020setupTests ( test ) ;
2121
22+ for ( const [ key , displayName ] of Object . entries (
23+ statusReport . ACTION_DISPLAY_NAMES ,
24+ ) ) {
25+ test ( `getDisplayActionName - '${ displayName } ' instead of '${ key } '` , ( t ) => {
26+ t . is ( statusReport . getDisplayActionName ( key as ActionName ) , displayName ) ;
27+ } ) ;
28+ }
29+
30+ test ( "getDisplayActionName - returns action name" , ( t ) => {
31+ for ( const actionName of Object . values ( ActionName ) ) {
32+ if ( statusReport . ACTION_DISPLAY_NAMES [ actionName ] ) {
33+ continue ;
34+ }
35+
36+ t . is ( statusReport . getDisplayActionName ( actionName ) , actionName ) ;
37+ }
38+ } ) ;
39+
2240interface RunInActionsTestOpts {
2341 runFn ?: ( ) => Promise < any > ;
2442 expectedErrorMessage ?: string ;
Original file line number Diff line number Diff line change @@ -61,15 +61,21 @@ export enum ActionName {
6161 UploadSarif = "upload-sarif" ,
6262}
6363
64+ /** A partial mapping from `ActionName` to names for actions whose display name is not the `ActionName` value. */
65+ export const ACTION_DISPLAY_NAMES : Partial < Record < ActionName , string > > = {
66+ [ ActionName . Analyze ] : "analyze" ,
67+ [ ActionName . InitPost ] : "init post" ,
68+ } ;
69+
6470/**
65- * Maps an ` ActionName` to its display name. Usually that is the same, except
66- * for `ActionName.Analyze` where it is `"analyze"` instead of `"finish"` .
71+ * Maps an { @link ActionName} to its display name. Usually that is the same, except
72+ * for actions which have a different display name in { @link ACTION_DISPLAY_NAMES} .
6773 */
6874export function getDisplayActionName ( actionName : ActionName ) : string {
69- if ( actionName === ActionName . Analyze ) {
70- return "analyze" ;
71- } else if ( actionName === ActionName . InitPost ) {
72- return "init post" ;
75+ const displayName = ACTION_DISPLAY_NAMES [ actionName ] ;
76+
77+ if ( displayName !== undefined ) {
78+ return displayName ;
7379 }
7480 return actionName ;
7581}
You can’t perform that action at this time.
0 commit comments