mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-05 12:03:15 +08:00
Core: Add trimWhitespace to getInput (#802)
* Add option to not trim whitespace from inputs * Fix typos * Add doc clarification * Rename options
This commit is contained in:
@@ -27,6 +27,7 @@ const testEnvVars = {
|
||||
INPUT_BOOLEAN_INPUT_FALSE2: 'False',
|
||||
INPUT_BOOLEAN_INPUT_FALSE3: 'FALSE',
|
||||
INPUT_WRONG_BOOLEAN_INPUT: 'wrong',
|
||||
INPUT_WITH_TRAILING_WHITESPACE: ' some val ',
|
||||
|
||||
// Save inputs
|
||||
STATE_TEST_1: 'state_val',
|
||||
@@ -165,6 +166,22 @@ describe('@actions/core', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('getInput trims whitespace by default', () => {
|
||||
expect(core.getInput('with trailing whitespace')).toBe('some val')
|
||||
})
|
||||
|
||||
it('getInput trims whitespace when option is explicitly true', () => {
|
||||
expect(
|
||||
core.getInput('with trailing whitespace', {trimWhitespace: true})
|
||||
).toBe('some val')
|
||||
})
|
||||
|
||||
it('getInput does not trim whitespace when option is false', () => {
|
||||
expect(
|
||||
core.getInput('with trailing whitespace', {trimWhitespace: false})
|
||||
).toBe(' some val ')
|
||||
})
|
||||
|
||||
it('getInput gets non-required boolean input', () => {
|
||||
expect(core.getBooleanInput('boolean input')).toBe(true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user