test: reformat jest test cases

Signed-off-by: Kengo TODA <skypencil@gmail.com>
This commit is contained in:
Kengo TODA
2022-09-04 09:33:35 +08:00
committed by Kengo TODA
parent c1ed1d87de
commit ececfe4aee

View File

@@ -1,24 +1,21 @@
import {install, runCommand} from '../src/install'
import * as core from '@actions/core'
import {expect, test} from '@jest/globals'
import {describe, expect, it, test} from '@jest/globals'
test('runCommand', async () => {
const result = await runCommand('echo foo bar')
expect(result).toBe('foo bar')
describe('runCommand', () => {
it('runs a command and returns its stdout', async () => {
const result = await runCommand('echo foo bar')
expect(result).toBe('foo bar')
})
})
async function testVersion(version: string) {
const commandPath = await install(version)
core.addPath(commandPath)
const result = await runCommand('docker-compose version')
expect(result).toContain(version)
}
test('Install the right version', async () => {
await testVersion('1.29.1')
await testVersion('1.29.2')
await testVersion('2.2.3')
await testVersion('v2.2.3')
await testVersion('v2.10.2')
describe('install', () => {
const cases = ['1.29.1', '1.29.2', '2.2.3', 'v2.2.3', 'v2.10.2']
test.each(cases)('can install version %p', async (version: string) => {
const commandPath = await install(version)
core.addPath(commandPath)
const result = await runCommand('docker-compose version')
expect(result).toContain(version)
})
})