From 5b06192e7cc40b4955128ef16a1505ecdcb0852a Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 22 May 2020 01:54:13 +0530 Subject: [PATCH] Improve install.ts tests --- __tests__/install.test.ts | 73 +++++++++++++++++---------------------- package-lock.json | 62 ++++++++++++++++++++++++--------- package.json | 8 ++--- 3 files changed, 81 insertions(+), 62 deletions(-) diff --git a/__tests__/install.test.ts b/__tests__/install.test.ts index f48dcd2b..a537558a 100644 --- a/__tests__/install.test.ts +++ b/__tests__/install.test.ts @@ -69,6 +69,7 @@ jest.mock('../src/install', () => ({ * @param extension_csv * @param ini_values_csv * @param coverage_driver + * @param tools */ function setEnv( version: string | number, @@ -76,8 +77,7 @@ function setEnv( extension_csv: string, ini_values_csv: string, coverage_driver: string, - tools: string, - pecl: string + tools: string ): void { process.env['php-version'] = version.toString(); process.env['RUNNER_OS'] = os; @@ -85,26 +85,25 @@ function setEnv( process.env['ini-values'] = ini_values_csv; process.env['coverage'] = coverage_driver; process.env['tools'] = tools; - process.env['pecl'] = pecl; } describe('Install', () => { it('Test install on windows', async () => { - setEnv('7.0', 'win32', '', '', '', '', ''); - // @ts-ignore - let script: string = await install.run(); + setEnv('7.0', 'win32', '', '', '', ''); + + let script: string = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname); - setEnv('7.3', 'win32', '', '', '', '', ''); - // @ts-ignore - script = await install.run(); + setEnv('7.3', 'win32', '', '', '', ''); + + script = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname); - setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '', ''); - // @ts-ignore - script = await install.run(); + setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', ''); + + script = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); @@ -113,25 +112,15 @@ describe('Install', () => { }); it('Test install on linux', async () => { - setEnv('7.3', 'linux', '', '', '', '', ''); - // @ts-ignore - let script: string = await install.run(); + setEnv('7.3', 'linux', '', '', '', ''); + + let script: string = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('bash script.sh 7.3 '); - setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', 'true'); - // @ts-ignore - script = await install.run(); - expect(script).toContain('initial script'); - expect(script).toContain('install extensions'); - expect(script).toContain('edit php.ini'); - expect(script).toContain('set coverage driver'); - expect(script).toContain('bash script.sh 7.3'); - expect(script).toContain('add_tool'); + setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit'); - setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', ''); - // @ts-ignore - script = await install.run(); + script = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); @@ -141,15 +130,15 @@ describe('Install', () => { }); it('Test install on darwin', async () => { - setEnv('7.3', 'darwin', '', '', '', '', ''); - // @ts-ignore - let script: string = await install.run(); + setEnv('7.3', 'darwin', '', '', '', ''); + + let script: string = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('bash script.sh 7.3 ' + __dirname); - setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '', ''); - // @ts-ignore - script = await install.run(); + setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', ''); + + script = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); @@ -158,21 +147,21 @@ describe('Install', () => { }); it('Test malformed version inputs', async () => { - setEnv('7.4.1', 'darwin', '', '', '', '', ''); - // @ts-ignore - let script: string = await install.run(); + setEnv('7.4.1', 'darwin', '', '', '', ''); + + let script: string = '' + '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('bash script.sh 7.4 ' + __dirname); - setEnv(8.0, 'darwin', '', '', '', '', ''); - // @ts-ignore - script = await install.run(); + setEnv(8.0, 'darwin', '', '', '', ''); + + script = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('bash script.sh 8.0 ' + __dirname); - setEnv(8, 'darwin', '', '', '', '', ''); - // @ts-ignore - script = await install.run(); + setEnv(8, 'darwin', '', '', '', ''); + + script = '' + (await install.run()); expect(script).toContain('initial script'); expect(script).toContain('bash script.sh 8.0 ' + __dirname); }); diff --git a/package-lock.json b/package-lock.json index 344f6a9c..eff72962 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1057,45 +1057,46 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz", - "integrity": "sha512-4zY3Z88rEE99+CNvTbXSyovv2z9PNOVffTWD2W8QF5s2prBQtwN2zadqERcrHpcR7O/+KMI3fcTAmUUhK/iQcQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.0.0.tgz", + "integrity": "sha512-lcZ0M6jD4cqGccYOERKdMtg+VWpoq3NSnWVxpc/AwAy0zhkUYVioOUZmfNqiNH8/eBNGhCn6HXd6mKIGRgNc1Q==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.34.0", + "@typescript-eslint/experimental-utils": "3.0.0", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", + "semver": "^7.3.2", "tsutils": "^3.17.1" } }, "@typescript-eslint/experimental-utils": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz", - "integrity": "sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.0.tgz", + "integrity": "sha512-BN0vmr9N79M9s2ctITtChRuP1+Dls0x/wlg0RXW1yQ7WJKPurg6X3Xirv61J2sjPif4F8SLsFMs5Nzte0WYoTQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.34.0", + "@typescript-eslint/typescript-estree": "3.0.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.34.0.tgz", - "integrity": "sha512-03ilO0ucSD0EPTw2X4PntSIRFtDPWjrVq7C3/Z3VQHRC7+13YB55rcJI3Jt+YgeHbjUdJPcPa7b23rXCBokuyA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.0.0.tgz", + "integrity": "sha512-8RRCA9KLxoFNO0mQlrLZA0reGPd/MsobxZS/yPFj+0/XgMdS8+mO8mF3BDj2ZYQj03rkayhSJtF1HAohQ3iylw==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.34.0", - "@typescript-eslint/typescript-estree": "2.34.0", + "@typescript-eslint/experimental-utils": "3.0.0", + "@typescript-eslint/typescript-estree": "3.0.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz", - "integrity": "sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.0.tgz", + "integrity": "sha512-nevQvHyNghsfLrrByzVIH4ZG3NROgJ8LZlfh3ddwPPH4CH7W4GAiSx5qu+xHuX5pWsq6q/eqMc1io840ZhAnUg==", "dev": true, "requires": { "debug": "^4.1.1", @@ -2253,6 +2254,35 @@ "dev": true, "requires": { "@typescript-eslint/experimental-utils": "^2.5.0" + }, + "dependencies": { + "@typescript-eslint/experimental-utils": { + "version": "2.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz", + "integrity": "sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.34.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz", + "integrity": "sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + } + } } }, "eslint-plugin-prettier": { diff --git a/package.json b/package.json index 448b000a..cc8be204 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,10 @@ "fs": "0.0.1-security" }, "devDependencies": { - "@types/jest": "^25.2.2", - "@types/node": "^14.0.1", - "@typescript-eslint/eslint-plugin": "^2.34.0", - "@typescript-eslint/parser": "^2.34.0", + "@types/jest": "^25.2.3", + "@types/node": "^14.0.4", + "@typescript-eslint/eslint-plugin": "^3.0.0", + "@typescript-eslint/parser": "^3.0.0", "@zeit/ncc": "^0.22.2", "eslint": "^7.0.0", "eslint-config-prettier": "^6.11.0",