Update readme
This commit is contained in:
@@ -2,7 +2,7 @@ import * as fs from 'fs'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import * as core from '../src/core'
|
||||
import { toCommandProperties } from '../src/utils'
|
||||
import {toCommandProperties} from '../src/utils'
|
||||
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
|
||||
@@ -142,17 +142,17 @@ describe('@actions/core', () => {
|
||||
})
|
||||
|
||||
it('getInput gets required input', () => {
|
||||
expect(core.getInput('my input', { required: true })).toBe('val')
|
||||
expect(core.getInput('my input', {required: true})).toBe('val')
|
||||
})
|
||||
|
||||
it('getInput throws on missing required input', () => {
|
||||
expect(() => core.getInput('missing', { required: true })).toThrow(
|
||||
expect(() => core.getInput('missing', {required: true})).toThrow(
|
||||
'Input required and not supplied: missing'
|
||||
)
|
||||
})
|
||||
|
||||
it('getInput does not throw on missing non-required input', () => {
|
||||
expect(core.getInput('missing', { required: false })).toBe('')
|
||||
expect(core.getInput('missing', {required: false})).toBe('')
|
||||
})
|
||||
|
||||
it('getInput is case insensitive', () => {
|
||||
@@ -183,13 +183,13 @@ describe('@actions/core', () => {
|
||||
|
||||
it('getInput trims whitespace when option is explicitly true', () => {
|
||||
expect(
|
||||
core.getInput('with trailing whitespace', { trimWhitespace: true })
|
||||
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 })
|
||||
core.getInput('with trailing whitespace', {trimWhitespace: false})
|
||||
).toBe(' some val ')
|
||||
})
|
||||
|
||||
@@ -198,7 +198,7 @@ describe('@actions/core', () => {
|
||||
})
|
||||
|
||||
it('getInput gets required input', () => {
|
||||
expect(core.getBooleanInput('boolean input', { required: true })).toBe(true)
|
||||
expect(core.getBooleanInput('boolean input', {required: true})).toBe(true)
|
||||
})
|
||||
|
||||
it('getBooleanInput handles boolean input', () => {
|
||||
@@ -213,7 +213,7 @@ describe('@actions/core', () => {
|
||||
it('getBooleanInput handles wrong boolean input', () => {
|
||||
expect(() => core.getBooleanInput('wrong boolean input')).toThrow(
|
||||
'Input does not meet YAML 1.2 "Core Schema" specification: wrong boolean input\n' +
|
||||
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``
|
||||
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``
|
||||
)
|
||||
})
|
||||
|
||||
@@ -272,8 +272,16 @@ describe('@actions/core', () => {
|
||||
|
||||
it('error handles parameters correctly', () => {
|
||||
const message = 'this is my error message'
|
||||
core.error(new Error(message), { title: 'A title', startColumn: 1, endColumn: 2, startLine: 5, endLine: 5 })
|
||||
assertWriteCalls([`::error title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`])
|
||||
core.error(new Error(message), {
|
||||
title: 'A title',
|
||||
startColumn: 1,
|
||||
endColumn: 2,
|
||||
startLine: 5,
|
||||
endLine: 5
|
||||
})
|
||||
assertWriteCalls([
|
||||
`::error title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`
|
||||
])
|
||||
})
|
||||
|
||||
it('warning sets the correct message', () => {
|
||||
@@ -294,12 +302,26 @@ describe('@actions/core', () => {
|
||||
|
||||
it('warning handles parameters correctly', () => {
|
||||
const message = 'this is my error message'
|
||||
core.warning(new Error(message), { title: 'A title', startColumn: 1, endColumn: 2, startLine: 5, endLine: 5 })
|
||||
assertWriteCalls([`::warning title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`])
|
||||
core.warning(new Error(message), {
|
||||
title: 'A title',
|
||||
startColumn: 1,
|
||||
endColumn: 2,
|
||||
startLine: 5,
|
||||
endLine: 5
|
||||
})
|
||||
assertWriteCalls([
|
||||
`::warning title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`
|
||||
])
|
||||
})
|
||||
|
||||
it('annotations map field names correctly', () => {
|
||||
const commandProperties = toCommandProperties({ title: 'A title', startColumn: 1, endColumn: 2, startLine: 5, endLine: 5 })
|
||||
const commandProperties = toCommandProperties({
|
||||
title: 'A title',
|
||||
startColumn: 1,
|
||||
endColumn: 2,
|
||||
startLine: 5,
|
||||
endLine: 5
|
||||
})
|
||||
expect(commandProperties.title).toBe('A title')
|
||||
expect(commandProperties.col).toBe(1)
|
||||
expect(commandProperties.end_column).toBe(2)
|
||||
|
||||
Reference in New Issue
Block a user