From ececfe4aee7825c69f3ba51783377360c558a650 Mon Sep 17 00:00:00 2001 From: Kengo TODA Date: Sun, 4 Sep 2022 09:33:35 +0800 Subject: [PATCH] test: reformat jest test cases Signed-off-by: Kengo TODA --- __tests__/install.test.ts | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/__tests__/install.test.ts b/__tests__/install.test.ts index ac241c6..fa968d2 100644 --- a/__tests__/install.test.ts +++ b/__tests__/install.test.ts @@ -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) + }) })