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.
Merge pull request #44 from stark-contrast/develop
Develop
- Loading branch information
Showing
12 changed files
with
958 additions
and
702 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
|
||
- name: Set Node.js 16.x | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
node-version: 16.x | ||
|
||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"runId":"summary","type":"pass","data":[{"name":"score","value":94.20289855072464},{"name":"passed","value":65},{"name":"failed","value":3},{"name":"potentials","value":1}]} | ||
{"runId":"summary","url":"testurl","type":"pass","data":[{"name":"score","value":94.20289855072464},{"name":"passed","value":65},{"name":"failed","value":3},{"name":"potentials","value":1}]} |
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,64 @@ | ||
import {afterEach, describe} from 'node:test' | ||
import {getInput} from '@actions/core' | ||
import {expect, jest, test} from '@jest/globals' | ||
import { | ||
InputParams, | ||
getCoreInputWithFallback, | ||
parseInputs | ||
} from '../src/parse-inputs' | ||
|
||
jest.mock('@actions/core', () => ({ | ||
getInput: jest.fn() | ||
})) | ||
|
||
describe('getCoreInputSafe', () => { | ||
test('should return value if it exists', () => { | ||
;(getInput as jest.Mock).mockReturnValueOnce('value') | ||
const value = getCoreInputWithFallback('somekey', 'default') | ||
expect(value).toBe('value') | ||
}) | ||
test('should return default value if it does not exist', () => { | ||
;(getInput as jest.Mock).mockReturnValueOnce(undefined) | ||
const value = getCoreInputWithFallback('somekey', 'default') | ||
expect(value).toBe('default') | ||
}) | ||
test('should return default value if it is empty', () => { | ||
;(getInput as jest.Mock).mockReturnValueOnce('') | ||
const value = getCoreInputWithFallback('somekey', 'default') | ||
expect(value).toBe('default') | ||
}) | ||
}) | ||
|
||
describe('parseInput', () => { | ||
afterEach(() => { | ||
;(getInput as jest.Mock).mockClear() | ||
}) | ||
test('should return correct default values', () => { | ||
;(getInput as jest.Mock).mockImplementation(key => { | ||
return key === 'url' ? 'localhost:3000/test' : '' | ||
}) | ||
const expectedInputs: InputParams = { | ||
setupScript: 'echo "No setup script"', | ||
preBuildScript: 'echo "No prebuild script"', | ||
buildScript: 'echo "No build script"', | ||
serveScript: 'echo "No serve script"', | ||
cleanupScript: 'echo "No cleanup script"', | ||
url: 'localhost:3000/test', | ||
minScore: '0', | ||
sleepTime: '5000', | ||
token: '' | ||
} | ||
|
||
const inputs = parseInputs() | ||
|
||
expect(inputs).toEqual(expectedInputs) | ||
}) | ||
test('should throw if url is not provided', () => { | ||
;(getInput as jest.Mock).mockImplementation(key => { | ||
if (key === 'url') throw new Error('') | ||
return '' | ||
}) | ||
|
||
expect(parseInputs).toThrowError() | ||
}) | ||
}) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.