mirror of
https://github.com/actions/github-script.git
synced 2026-02-08 03:57:27 +00:00
chore: Make test run names able to handle refactoring
`fn.name` was introduced in Node 0.10.0, so this improves test suite maintainability without changing the minimum node version. Also added a test that for certain proves that Promises can be awaited.
This commit is contained in:
parent
60a0d83039
commit
ccf1a8e117
2 changed files with 11 additions and 3 deletions
|
|
@ -2,13 +2,21 @@
|
||||||
|
|
||||||
import {callAsyncFunction} from '../src/async-function'
|
import {callAsyncFunction} from '../src/async-function'
|
||||||
|
|
||||||
describe('callAsyncFunction', () => {
|
describe(callAsyncFunction.name, () => {
|
||||||
test('calls the function with its arguments', async () => {
|
test('calls the function with its arguments', async () => {
|
||||||
const result = await callAsyncFunction({foo: 'bar'} as any, 'return foo')
|
const result = await callAsyncFunction({foo: 'bar'} as any, 'return foo')
|
||||||
expect(result).toEqual('bar')
|
expect(result).toEqual('bar')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('throws on ReferenceError', async () => {
|
test('can await a Promise', async () => {
|
||||||
|
const result = await callAsyncFunction(
|
||||||
|
{} as any,
|
||||||
|
'return await new Promise(resolve => resolve("bar"))'
|
||||||
|
)
|
||||||
|
expect(result).toEqual('bar')
|
||||||
|
})
|
||||||
|
|
||||||
|
test(`throws an ${ReferenceError.name}`, async () => {
|
||||||
expect.assertions(1)
|
expect.assertions(1)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import {getRetryOptions} from '../src/retry-options'
|
import {getRetryOptions} from '../src/retry-options'
|
||||||
|
|
||||||
describe('getRequestOptions', () => {
|
describe(getRetryOptions.name, () => {
|
||||||
test('retries disabled if retries == 0', async () => {
|
test('retries disabled if retries == 0', async () => {
|
||||||
const [retryOptions, requestOptions] = getRetryOptions(
|
const [retryOptions, requestOptions] = getRetryOptions(
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue