Skip to content

Commit

Permalink
Refactor tests to __tests__ dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaskello committed Oct 20, 2020
1 parent 614d2da commit fb162b7
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
extends: "divid",
parserOptions: {
project: ["./src/tsconfig.json", "./test/tsconfig.json"]
project: ["./src/tsconfig.json"]
}
};
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/__tests__/**
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased](https://github.com/dividab/uom/compare/v5.0.0...master)

- Refactor tests, move to `__tests__` folder

## [v5.0.0](https://github.com/dividab/uom/compare/v4.1.0...v5.0.0) - 2020-10-08

### Changed

- The consumer of the package is responsible for sending in a unit lookup function. See PR [#51](https://github.com/dividab/uom/pull/51).

## [v4.1.0](https://github.com/dividab/uom/compare/v4.0.0...v4.1.0) - 2020-03-29
Expand Down
28 changes: 18 additions & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
// module.exports = {
// preset: "ts-jest",
// testEnvironment: "node",
// testRegex: "./test/.+\\.test\\.ts$",
// collectCoverage: true,
// collectCoverageFrom: ["src/**/*.ts"],
// moduleFileExtensions: ["ts", "js", "json", "node"],
// coverageReporters: ["text-summary", "lcov"],
// globals: {
// "ts-jest": {
// tsConfig: "<rootDir>/test/tsconfig.json"
// }
// }
// };

module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testRegex: "./test/.+\\.test\\.ts$",
testMatch: ["<rootDir>/src/**/*.test.{ts,tsx}"],
coverageDirectory: "<rootDir>/coverage/",
collectCoverage: true,
collectCoverageFrom: ["src/**/*.ts"],
moduleFileExtensions: ["ts", "js", "json", "node"],
coverageReporters: ["text-summary", "lcov"],
globals: {
"ts-jest": {
tsConfig: "<rootDir>/test/tsconfig.json"
}
}
collectCoverageFrom: ["**/src/**/!(*.test).{ts,tsx}", "!(**/__tests__/**)"],
};
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"eslint-config-divid": "^0.4.2",
"eslint-plugin-functional": "^1.0.0",
"eslint-plugin-import": "^2.18.2",
"husky": "^0.14.3",
"husky": "^4.3.0",
"jest": "^24.9.0",
"jsdoc-to-markdown": "^5.0.1",
"lint-staged": "^7.2.0",
Expand All @@ -39,20 +39,18 @@
},
"scripts": {
"lint": "eslint './{src,test}/**/*.ts' --ext .ts -f visualstudio ",
"build": "yarn build:clean && yarn build:cjs && yarn build:esm && yarn gen-docs",
"build:clean": "rm -rf ./lib-cjs ./lib-esm",
"build": "yarn clean && yarn build:cjs && yarn build:esm && yarn gen-docs",
"clean": "rm -rf ./lib-cjs ./lib-esm",
"build:cjs": "tsc -p src",
"build:esm": "tsc -p src --module es2015 --moduleResolution node --outDir ./lib-esm",
"test:build": "tsc -p test",
"test:build:clean": "rm -rf ./lib-test",
"test-coverage": "jest",
"test": "jest --no-coverage",
"verify": "yarn lint && yarn build && yarn test-coverage",
"precommit": "lint-staged",
"test-coverage": "jest",
"report-coverage": "codecov -f coverage/lcov.info",
"gen-docs": "jsdoc2md --partial docs/scope.hbs --files lib-esm/serialize.js lib-esm/format.js lib-esm/amount.js lib-esm/unit.js > docs/api.md",
"preversion": "git checkout master && git pull && yarn test && yarn build",
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push --follow-tags && echo \"Successfully released version $npm_package_version!\""
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push --follow-tags && echo \"Successfully released version $npm_package_version!\"",
"precommit": "lint-staged"
},
"lint-staged": {
"*.{ts,tsx}": "eslint --ext .ts -f visualstudio",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Amount, BaseUnits } from "../src";
// import { Units } from "../src/all-units";
import * as Amount from "../amount";
import * as BaseUnits from "../base-units";

describe("amount_compare_test", () => {
test("default_comparer_true", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/amount.test.ts → src/__tests__/amount.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Amount, BaseUnits } from "../src";
// import { Units } from "../src/all-units";
import * as Amount from "../amount";
import * as BaseUnits from "../base-units";
import { closeTo } from "./test-utils";

// TODO: Add typing tests:
Expand Down
6 changes: 3 additions & 3 deletions test/format.test.ts → src/__tests__/format.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Format, BaseUnits } from "../src";
import { createUnitFormat } from "../src/unit-format";
// import { Units, UnitsFormat } from "../src/all-units";
import * as Format from "../format";
import * as BaseUnits from "../base-units";
import { createUnitFormat } from "../unit-format";

const containsAll = <T>(
arr1: ReadonlyArray<T>,
Expand Down
6 changes: 3 additions & 3 deletions test/serialize.test.ts → src/__tests__/serialize.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import { Units } from "../src/all-units";
import { Serialize, BaseUnits } from "../src";
import { UnitMap } from "../src/unit";
import * as Serialize from "../serialize";
import * as BaseUnits from "../base-units";
import { UnitMap } from "../unit";

const baseUnitsLower = Object.keys(BaseUnits).reduce(
(soFar, current) => {
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions test/unit.test.ts → src/__tests__/unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Unit, BaseUnits } from "../src";
// import { Units } from "../src/all-units";
// import { closeTo } from "./test-utils";
import * as Unit from "../unit";
import * as BaseUnits from "../base-units";

describe("derived units", () => {
test("Meter times Meter should return unit with 1 element of pow 2", done => {
Expand Down
6 changes: 3 additions & 3 deletions test/units.test.ts → src/__tests__/units.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Unit, Serialize, BaseUnits } from "../src";
// import { Units } from "../src/all-units";
// import * as Quantity from "../src/quantity";
import * as Unit from "../unit";
import * as Serialize from "../serialize";
import * as BaseUnits from "../base-units";

// TODO: Add typing tests:
// export const pass: Quantity.Length = Units.CentiMeter;
Expand Down
Loading

0 comments on commit fb162b7

Please sign in to comment.