From 6a26145d6f9c1fb6e1a86297c6470d916d68e743 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 12 Jan 2022 09:32:13 +0100 Subject: [PATCH] fix tests --- libs/remix-solidity/jest.config.js | 24 +++++++++++++++ libs/remix-solidity/package.json | 1 - libs/remix-solidity/test/compiler-input.ts | 29 ------------------- .../tests/compiler-input.spec.ts | 25 ++++++++++++++++ libs/remix-solidity/tsconfig.json | 3 +- workspace.json | 6 ++-- 6 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 libs/remix-solidity/jest.config.js delete mode 100644 libs/remix-solidity/test/compiler-input.ts create mode 100644 libs/remix-solidity/tests/compiler-input.spec.ts diff --git a/libs/remix-solidity/jest.config.js b/libs/remix-solidity/jest.config.js new file mode 100644 index 0000000000..abfff6a986 --- /dev/null +++ b/libs/remix-solidity/jest.config.js @@ -0,0 +1,24 @@ +module.exports = { + name: 'remix-solidity', + preset: '../../jest.config.js', + verbose: true, + silent: false, // Silent console messages, specially the 'remix-simulator' ones + transform: { + '^.+\\.[tj]sx?$': 'ts-jest', + }, + transformIgnorePatterns: ["/node_modules/", "/dist/", "\\.pnp\\.[^\\\/]+$"], + rootDir: "./", + testTimeout: 40000, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html', 'json'], + // Coverage + collectCoverage: true, + coverageReporters: ['text', 'text-summary'], + collectCoverageFrom: [ + "**/*.ts", + "!**/sol/**", + "!src/types.ts", + "!src/logger.ts" + ], + coverageDirectory: '../../coverage/libs/remix-solidity' + }; + \ No newline at end of file diff --git a/libs/remix-solidity/package.json b/libs/remix-solidity/package.json index 7f90f6ee3c..fdfaca6c02 100644 --- a/libs/remix-solidity/package.json +++ b/libs/remix-solidity/package.json @@ -41,7 +41,6 @@ "@types/node": "^13.1.1", "babel-eslint": "^10.0.0", "babelify": "^10.0.0", - "tape": "^4.6.0", "typescript": "^3.7.4" }, "scripts": { diff --git a/libs/remix-solidity/test/compiler-input.ts b/libs/remix-solidity/test/compiler-input.ts deleted file mode 100644 index ba735ff023..0000000000 --- a/libs/remix-solidity/test/compiler-input.ts +++ /dev/null @@ -1,29 +0,0 @@ -'use strict' -import tape from 'tape' -import { getValidLanguage } from '../src/compiler/compiler-input' -import { Language } from '../src/compiler/types' - -tape('compiler-input', function (t) { - t.test('getValidLanguage', function (st) { - st.plan(9) - - const correctYul: Language = 'Yul' - const correctSolidity: Language = 'Solidity' - - const yulUpperCase = 'Yul' - const yulLowerCase = 'yul' - - const solidityUpperCase = 'Solidity' - const solidityLowerCase = 'solidity' - - st.equal(getValidLanguage(yulLowerCase), correctYul) - st.equal(getValidLanguage(yulUpperCase), correctYul) - st.equal(getValidLanguage(solidityUpperCase), correctSolidity) - st.equal(getValidLanguage(solidityLowerCase), correctSolidity) - st.equal(getValidLanguage(null), null) - st.equal(getValidLanguage(undefined), null) - st.equal(getValidLanguage(''), null) - st.equal(getValidLanguage('A'), null) - st.equal(getValidLanguage('Something'), null) - }) -}) diff --git a/libs/remix-solidity/tests/compiler-input.spec.ts b/libs/remix-solidity/tests/compiler-input.spec.ts new file mode 100644 index 0000000000..3dc247624b --- /dev/null +++ b/libs/remix-solidity/tests/compiler-input.spec.ts @@ -0,0 +1,25 @@ +import { getValidLanguage } from '../src/compiler/compiler-input' +import { Language } from '../src/compiler/types' + +describe('compiler-input', () => { + test('getValidLanguage', () => { + const correctYul: Language = 'Yul' + const correctSolidity: Language = 'Solidity' + + const yulUpperCase = 'Yul' + const yulLowerCase = 'yul' + + const solidityUpperCase = 'Solidity' + const solidityLowerCase = 'solidity' + + expect(getValidLanguage(yulLowerCase)).toBe(correctYul) + expect(getValidLanguage(yulUpperCase)).toBe(correctYul) + expect(getValidLanguage(solidityUpperCase)).toBe(correctSolidity) + expect(getValidLanguage(solidityLowerCase)).toBe(correctSolidity) + expect(getValidLanguage(null)).toBe(null) + expect(getValidLanguage(undefined)).toBe(null) + expect(getValidLanguage('')).toBe(null) + expect(getValidLanguage('A')).toBe(null) + expect(getValidLanguage('Something')).toBe(null) + }) +}) diff --git a/libs/remix-solidity/tsconfig.json b/libs/remix-solidity/tsconfig.json index 7f163468b2..ec3a5d0c25 100644 --- a/libs/remix-solidity/tsconfig.json +++ b/libs/remix-solidity/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "types": ["node"], - "esModuleInterop": true + "types": ["jest", "node"] }, "include": ["**/*.ts"] } \ No newline at end of file diff --git a/workspace.json b/workspace.json index 5ff3f1ca9f..8e78b40751 100644 --- a/workspace.json +++ b/workspace.json @@ -309,10 +309,10 @@ } }, "test": { - "builder": "@nrwl/workspace:run-commands", + "builder": "@nrwl/jest:jest", "options": { - "commands": ["./../../node_modules/.bin/npm-run-all test"], - "cwd": "libs/remix-solidity" + "jestConfig": "libs/remix-solidity/jest.config.js", + "tsConfig": "libs/remix-solidity/tsconfig.spec.json" } }, "build": {