generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix linting errors and disable some linting rules
- Loading branch information
Showing
6 changed files
with
102 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import * as exec from '@actions/exec' | ||
import { expect } from '@jest/globals' | ||
|
||
export function makeGitExecMock( | ||
stdout: string | ||
): ( | ||
commandLine: string, | ||
args?: string[] | undefined, | ||
options?: exec.ExecOptions | undefined | ||
) => Promise<number> { | ||
return async ( | ||
commandLine: string, | ||
args?: string[] | undefined, | ||
options?: exec.ExecOptions | undefined | ||
): Promise<number> => { | ||
expect(commandLine).toBe('git') | ||
expect(args).toStrictEqual(['tag', '--sort=-v:refname']) | ||
expect(options).toBeDefined() | ||
expect(options).not.toBeNull() | ||
if (options) { | ||
expect(options.listeners).toBeDefined() | ||
expect(options.listeners).not.toBeNull() | ||
if (options.listeners) { | ||
expect(options.listeners.stdout).toBeDefined() | ||
expect(options.listeners.stdout).not.toBeNull() | ||
expect(options.listeners.stderr).toBeDefined() | ||
expect(options.listeners.stderr).not.toBeNull() | ||
if (options.listeners.stdout) { | ||
options.listeners.stdout(Buffer.from(stdout)) | ||
} | ||
if (options.listeners.stderr) { | ||
options.listeners.stderr(Buffer.from('')) | ||
} | ||
} | ||
} | ||
return new Promise(resolve => { | ||
resolve(0) | ||
}) | ||
} | ||
} | ||
|
||
export function makeOctokitMock( | ||
...bumpLabel: string[] | ||
): (token: string) => any { | ||
Check warning on line 44 in __tests__/helpers.ts GitHub Actions / Lint Code Base
|
||
const labels = [{ name: 'dependency' }] | ||
if (bumpLabel !== undefined) { | ||
labels.push( | ||
...bumpLabel.map((l: string) => { | ||
return { name: l } | ||
}) | ||
) | ||
} | ||
return (token: string): any => { | ||
Check warning on line 53 in __tests__/helpers.ts GitHub Actions / Lint Code Base
|
||
expect(token).toBe('mock-token') | ||
return { | ||
rest: { | ||
pulls: { | ||
get: async (req: any) => { | ||
Check warning on line 58 in __tests__/helpers.ts GitHub Actions / Lint Code Base
|
||
expect(req.owner).toBe('projectsyn') | ||
expect(req.repo).toBe('pr-label-tag-action') | ||
expect(req.pull_number).toBe(123) | ||
return new Promise(resolve => { | ||
resolve({ | ||
data: { | ||
labels | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.