-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
omit
input, deprecate others (#15)
* add omit input, deprecate others * naming * docs + additional dist checking * quickstart
- Loading branch information
Showing
13 changed files
with
398 additions
and
143 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
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,83 @@ | ||
import * as core from '@actions/core' | ||
import { OmitOption, getInputs } from '../src/inputs' | ||
|
||
jest.mock('@actions/core') | ||
|
||
const mockGetInput = core.getInput as jest.MockedFunction<typeof core.getInput> | ||
const mockGetBooleanInput = core.getBooleanInput as jest.MockedFunction< | ||
typeof core.getBooleanInput | ||
> | ||
|
||
const mockInput = (name: string, value: string) => { | ||
mockGetInput.mockImplementation((n: string) => (n === name ? value : '')) | ||
} | ||
|
||
describe('renderer', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks() | ||
}) | ||
|
||
it('uses default values', () => { | ||
mockGetInput.mockReturnValue('') | ||
const inputs = getInputs() | ||
|
||
expect(inputs).toEqual({ | ||
moduleDirectory: '.', | ||
testArguments: ['./...'], | ||
fromJSONFile: null, | ||
omit: new Set(), | ||
}) | ||
}) | ||
|
||
it('parses moduleDirectory', () => { | ||
mockInput('moduleDirectory', 'foo') | ||
const inputs = getInputs() | ||
|
||
expect(inputs.moduleDirectory).toEqual('foo') | ||
}) | ||
|
||
it('parses testArguments', () => { | ||
mockInput('testArguments', 'foo bar') | ||
const inputs = getInputs() | ||
|
||
expect(inputs.testArguments).toEqual(['foo', 'bar']) | ||
}) | ||
|
||
it('parses fromJSONFile', () => { | ||
mockInput('fromJSONFile', 'foo.json') | ||
const inputs = getInputs() | ||
|
||
expect(inputs.fromJSONFile).toEqual('foo.json') | ||
}) | ||
|
||
it('parses omit', () => { | ||
mockInput( | ||
'omit', | ||
[...Object.values(OmitOption), 'foo', 'bar', 'baz'].join('\n') | ||
) | ||
const inputs = getInputs() | ||
|
||
expect(inputs.omit).toEqual(new Set(Object.values(OmitOption))) | ||
}) | ||
|
||
it('supports deprecated inputs', () => { | ||
mockGetInput.mockImplementation((name: string) => { | ||
switch (name) { | ||
case 'omitUntestedPackages': | ||
case 'omitSuccessfulPackages': | ||
case 'omitPie': | ||
return 'true' | ||
default: | ||
return '' | ||
} | ||
}) | ||
|
||
mockGetBooleanInput.mockReturnValue(true) | ||
|
||
const inputs = getInputs() | ||
expect(inputs.omit).toEqual( | ||
new Set([OmitOption.Untested, OmitOption.Successful, OmitOption.Pie]) | ||
) | ||
expect(core.warning).toHaveBeenCalled() | ||
}) | ||
}) |
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
Oops, something went wrong.