From 15e57b56d6d6a48546781c4ee67e57691b858aa4 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 22 Dec 2022 00:43:00 +0100 Subject: [PATCH] add mock --- __tests__/main.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index e19ea56a..b1d88f0c 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -11,6 +11,7 @@ import each from 'jest-each'; import * as main from '../src/main'; import * as util from '../src/util'; +import OfficialBuilds from '../src/distibutions/official_builds/official_builds'; describe('main tests', () => { let inputs = {} as any; @@ -32,12 +33,16 @@ describe('main tests', () => { let findSpy: jest.SpyInstance; let isCacheActionAvailable: jest.SpyInstance; + let getNodeJsInfoSpy: jest.SpyInstance; + beforeEach(() => { inputs = {}; // node os = {}; console.log('::stop-commands::stoptoken'); + process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out + process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out infoSpy = jest.spyOn(core, 'info'); infoSpy.mockImplementation(() => {}); setOutputSpy = jest.spyOn(core, 'setOutput'); @@ -64,6 +69,9 @@ describe('main tests', () => { // uncomment to debug // process.stderr.write('write:' + line + '\n'); }); + + getNodeJsInfoSpy = jest.spyOn(OfficialBuilds.prototype, 'getNodeJsInfo'); + getNodeJsInfoSpy.mockImplementation(() => {}); }); afterEach(() => { @@ -145,7 +153,7 @@ describe('main tests', () => { // Assert expect(parseNodeVersionSpy).toHaveBeenCalledTimes(0); - }); + }, 10000); it('not used if node-version-file not provided', async () => { // Act