From 2e5b10e3bdfa914fbe7f10ae06d82065f52c8d6d Mon Sep 17 00:00:00 2001 From: Tatyana Kostromskaya <32135588+takost@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:45:26 +0000 Subject: [PATCH] fix tests --- .../github/__tests__/github.proxy.test.ts | 8 ++--- packages/github/__tests__/github.test.ts | 4 +-- packages/github/package-lock.json | 31 +++++++++++++++++++ packages/github/package.json | 5 +-- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/packages/github/__tests__/github.proxy.test.ts b/packages/github/__tests__/github.proxy.test.ts index fd6154bb..86c51fc2 100644 --- a/packages/github/__tests__/github.proxy.test.ts +++ b/packages/github/__tests__/github.proxy.test.ts @@ -1,13 +1,13 @@ import * as http from 'http' import * as https from 'https' -import * as proxy from 'proxy' +import { createProxy } from 'proxy' // Default values are set when the module is imported, so we need to set proxy first. const proxyUrl = 'http://127.0.0.1:8081' const originalProxyUrl = process.env['https_proxy'] process.env['https_proxy'] = proxyUrl // eslint-disable-next-line import/first -import {getOctokit} from '../src/github' +import { getOctokit } from '../src/github' describe('@actions/github', () => { let proxyConnects: string[] @@ -16,7 +16,7 @@ describe('@actions/github', () => { beforeAll(async () => { // Start proxy server - proxyServer = proxy.createProxy() + proxyServer = createProxy() await new Promise(resolve => { const port = Number(proxyUrl.split(':')[2]) proxyServer.listen(port, () => resolve()) @@ -70,7 +70,7 @@ describe('@actions/github', () => { const repository = await octokit.graphql( '{repository(owner:"actions", name:"toolkit"){name}}' ) - expect(repository).toEqual({repository: {name: 'toolkit'}}) + expect(repository).toEqual({ repository: { name: 'toolkit' } }) expect(proxyConnects).toEqual(['api.github.com:443']) }) diff --git a/packages/github/__tests__/github.test.ts b/packages/github/__tests__/github.test.ts index c33937b8..a1ba44ce 100644 --- a/packages/github/__tests__/github.test.ts +++ b/packages/github/__tests__/github.test.ts @@ -1,5 +1,5 @@ import * as http from 'http' -import * as proxy from 'proxy' +import { createProxy } from 'proxy' import {getOctokit} from '../src/github' import {GitHub, getOctokitOptions} from '../src/utils' @@ -12,7 +12,7 @@ describe('@actions/github', () => { beforeAll(async () => { // Start proxy server - proxyServer = proxy.createProxy() + proxyServer = createProxy() await new Promise(resolve => { const port = Number(proxyUrl.split(':')[2]) proxyServer.listen(port, () => resolve(null)) diff --git a/packages/github/package-lock.json b/packages/github/package-lock.json index 48caadc8..5a1824b5 100644 --- a/packages/github/package-lock.json +++ b/packages/github/package-lock.json @@ -15,6 +15,7 @@ "@octokit/plugin-rest-endpoint-methods": "^7.2.3" }, "devDependencies": { + "@types/proxy": "^1.0.1", "proxy": "^2.1.1" } }, @@ -161,6 +162,21 @@ "@octokit/openapi-types": "^18.0.0" } }, + "node_modules/@types/node": { + "version": "20.6.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.1.tgz", + "integrity": "sha512-4LcJvuXQlv4lTHnxwyHQZ3uR9Zw2j7m1C9DfuwoTFQQP4Pmu04O6IfLYgMmHoOCt0nosItLLZAH+sOrRE0Bo8g==", + "dev": true + }, + "node_modules/@types/proxy": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/proxy/-/proxy-1.0.1.tgz", + "integrity": "sha512-vjRgU9Ke0+6sfVeAXQphHRGb+OgBNpah1fma4aP7Pto2rnlrPDjsq+vyvy7emw+Fc9ppEciQtRh9Gaaxzu1Gzw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -516,6 +532,21 @@ "@octokit/openapi-types": "^18.0.0" } }, + "@types/node": { + "version": "20.6.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.1.tgz", + "integrity": "sha512-4LcJvuXQlv4lTHnxwyHQZ3uR9Zw2j7m1C9DfuwoTFQQP4Pmu04O6IfLYgMmHoOCt0nosItLLZAH+sOrRE0Bo8g==", + "dev": true + }, + "@types/proxy": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/proxy/-/proxy-1.0.1.tgz", + "integrity": "sha512-vjRgU9Ke0+6sfVeAXQphHRGb+OgBNpah1fma4aP7Pto2rnlrPDjsq+vyvy7emw+Fc9ppEciQtRh9Gaaxzu1Gzw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", diff --git a/packages/github/package.json b/packages/github/package.json index 28973fcb..fbfddbd6 100644 --- a/packages/github/package.json +++ b/packages/github/package.json @@ -44,6 +44,7 @@ "@octokit/plugin-rest-endpoint-methods": "^7.2.3" }, "devDependencies": { - "proxy": "^2.1.1" + "proxy": "^2.1.1", + "@types/proxy": "^1.0.1" } -} \ No newline at end of file +}