From a39177280230ee98b0de17f8519e942134f04d63 Mon Sep 17 00:00:00 2001 From: Technote Date: Sun, 16 Oct 2022 03:09:55 +0900 Subject: [PATCH 1/3] chore: update packages --- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index cabba5d5..e97181ca 100644 --- a/package.json +++ b/package.json @@ -50,13 +50,13 @@ "@rollup/plugin-typescript": "^9.0.1", "@sindresorhus/tsconfig": "^3.0.1", "@types/js-yaml": "^4.0.5", - "@types/node": "^18.8.5", + "@types/node": "^18.11.0", "@typescript-eslint/eslint-plugin": "^5.40.0", "@typescript-eslint/parser": "^5.40.0", "@vitest/coverage-c8": "^0.24.3", "eslint": "^8.25.0", "eslint-plugin-import": "^2.26.0", - "rollup": "^3.1.0", + "rollup": "^3.2.0", "typescript": "^4.8.4" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index 4e0e0a57..71b06c55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -279,10 +279,10 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== -"@types/node@*", "@types/node@^18.8.5": - version "18.8.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.8.5.tgz#6a31f820c1077c3f8ce44f9e203e68a176e8f59e" - integrity sha512-Bq7G3AErwe5A/Zki5fdD3O6+0zDChhg671NfPjtIcbtzDNZTv4NPKMRFr7gtYPG7y+B8uTiNK4Ngd9T0FTar6Q== +"@types/node@*", "@types/node@^18.11.0": + version "18.11.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.0.tgz#f38c7139247a1d619f6cc6f27b072606af7c289d" + integrity sha512-IOXCvVRToe7e0ny7HpT/X9Rb2RYtElG1a+VshjwT00HxrM2dWBApHQoqsI6WiY7Q03vdf2bCrIGzVrkF/5t10w== "@typescript-eslint/eslint-plugin@^5.40.0": version "5.40.0" @@ -1683,10 +1683,10 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -rollup@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.1.0.tgz#1310c764ee3187cd39d936c85107f4bfb0cae3d7" - integrity sha512-GEvr+COcXicr4nuih6mpt2Eydq5lZ72z0RrKx1H4/Q2ouT34OHrIIJ9OUj2sZqUhq7QL8Hp8Q8BoWbjL/6ccRQ== +rollup@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.2.0.tgz#a6f44074418e55217967c8eca622f9638d396388" + integrity sha512-0ZkFPyBNvx717KvC700NoxUD31aEEX675u6INJVAmBgKtQuCL8jmmJCj1b9B/qDSnILAvASVKa7UpGS+FLN6AQ== optionalDependencies: fsevents "~2.3.2" From 73dbffb346fb640ba5bcb54ac40c7c8aae793cf7 Mon Sep 17 00:00:00 2001 From: Technote Date: Sun, 16 Oct 2022 03:10:14 +0900 Subject: [PATCH 2/3] feat: add helper method --- src/command.test.ts | 18 ++++++++++++++++-- src/command.ts | 10 ++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/command.test.ts b/src/command.test.ts index 01b20b25..46f717f3 100644 --- a/src/command.test.ts +++ b/src/command.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-magic-numbers */ -import { addPath, exportVariable } from '@actions/core'; +import { addPath, exportVariable, setOutput } from '@actions/core'; import { describe, it } from 'vitest'; -import { spyOnExportVariable, exportVariableCalledWith, spyOnAddPath, addPathCalledWith } from './command.js'; +import { spyOnExportVariable, exportVariableCalledWith, spyOnAddPath, addPathCalledWith, spyOnSetOutput, setOutputCalledWith } from './command.js'; describe('spyOnExportVariable, exportVariableCalledWith', () => { it('should spy on exportVariable', () => { @@ -27,3 +27,17 @@ describe('spyOnAddPath, addPathCalledWith', () => { addPathCalledWith(spy, ['test-path1', 'test-path2']); }); }); + +describe('spyOnSetOutput, setOutputCalledWith', () => { + it('should spy on setOutput', () => { + const spy = spyOnSetOutput(); + + setOutput('test-name1', 'test-value1'); + setOutput('test-name2', ['test-value2-1', 'test-value2-2']); + + setOutputCalledWith(spy, [ + { name: 'test-name1', value: 'test-value1' }, + { name: 'test-name2', value: ['test-value2-1', 'test-value2-2'] }, + ]); + }); +}); diff --git a/src/command.ts b/src/command.ts index ceb90d9b..604a3200 100644 --- a/src/command.ts +++ b/src/command.ts @@ -22,3 +22,13 @@ export const addPathCalledWith = (spyOnMock: SpyInstance, paths: string[]): void expect(spyOnMock.mock.calls[index]![0]).toBe(path); }); }; + +export const spyOnSetOutput = (): SpyInstance => vi.spyOn(core, 'setOutput').mockReturnValue(); +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const setOutputCalledWith = (spyOnMock: SpyInstance, pairs: { name: string, value: any }[]): void => { + expect(spyOnMock).toBeCalledTimes(pairs.length); + pairs.forEach(({ name, value }, index) => { + expect(spyOnMock.mock.calls[index]![0]).toBe(name); + expect(spyOnMock.mock.calls[index]![1]).toEqual(value); + }); +}; From f01490364b96b98157704e9080bf1d34173c433e Mon Sep 17 00:00:00 2001 From: Technote Date: Sun, 16 Oct 2022 03:11:27 +0900 Subject: [PATCH 3/3] feat: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e97181ca..2ed61f2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/github-action-test-helper", - "version": "0.10.0", + "version": "0.11.0", "description": "Test helper for GitHub Actions.", "keywords": [ "github",