@jikan0/test-utils 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
- # test-utils
1
+ # Test utilities
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ A reusable example workout for timer consumers and tests.
4
4
 
5
- ## Building
5
+ ```ts
6
+ import { BASIC_EXERCISE_PROGRAM } from '@jikan0/test-utils';
7
+ import { empty, push } from '@jikan0/fsm';
6
8
 
7
- Run `nx build test-utils` to build the library.
9
+ const result = push(BASIC_EXERCISE_PROGRAM)(empty);
10
+ ```
8
11
 
9
- ## Running unit tests
10
-
11
- Run `nx test test-utils` to execute the unit tests via [Jest](https://jestjs.io).
12
+ Durations are milliseconds; the exported program is readonly. See the
13
+ [engine](../fsm/README.md) and [development](../docs/development.md).
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/testUtils"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
@@ -0,0 +1,12 @@
1
+ type BasicRoundType = 'warmup' | 'exercise' | 'rest' | 'cooldown';
2
+ export declare const BASIC_EXERCISE_PROGRAM: readonly [{
3
+ readonly kind: 'warmup';
4
+ readonly duration: number;
5
+ }, ...{
6
+ kind: BasicRoundType;
7
+ duration: number;
8
+ }[], {
9
+ readonly kind: 'cooldown';
10
+ readonly duration: number;
11
+ }];
12
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASIC_EXERCISE_PROGRAM = void 0;
4
+ exports.BASIC_EXERCISE_PROGRAM = (() => {
5
+ const ONE_MINUTE = 60 * 1000;
6
+ const TOTAL_ROUNDS = 10;
7
+ const WARMUP_DURATION = 5 * ONE_MINUTE;
8
+ const EXERCISE_DURATION = 3 * ONE_MINUTE;
9
+ // noinspection PointlessArithmeticExpressionJS
10
+ const REST_DURATION = 1 * ONE_MINUTE;
11
+ const COOLDOWN_DURATION = 5 * ONE_MINUTE;
12
+ const DURATIONS = {
13
+ warmup: WARMUP_DURATION,
14
+ exercise: EXERCISE_DURATION,
15
+ rest: REST_DURATION,
16
+ cooldown: COOLDOWN_DURATION,
17
+ };
18
+ return [
19
+ {
20
+ kind: 'warmup',
21
+ duration: WARMUP_DURATION,
22
+ },
23
+ ...[...Array(TOTAL_ROUNDS * 2 - 1 /*cut last rest*/).keys()]
24
+ .map((i) => (i % 2 === 0 ? 'exercise' : 'rest'))
25
+ .map((kind) => ({
26
+ kind,
27
+ duration: DURATIONS[kind],
28
+ })),
29
+ {
30
+ kind: 'cooldown',
31
+ duration: COOLDOWN_DURATION,
32
+ },
33
+ ];
34
+ })();
35
+ //# sourceMappingURL=testUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../../src/lib/testUtils.ts"],"names":[],"mappings":";;;AACa,QAAA,sBAAsB,GAAG,CAAC,GAAG,EAAE;IAC1C,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;IAC7B,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,MAAM,eAAe,GAAG,CAAC,GAAG,UAAU,CAAC;IACvC,MAAM,iBAAiB,GAAG,CAAC,GAAG,UAAU,CAAC;IACzC,+CAA+C;IAC/C,MAAM,aAAa,GAAG,CAAC,GAAG,UAAU,CAAC;IACrC,MAAM,iBAAiB,GAAG,CAAC,GAAG,UAAU,CAAC;IACzC,MAAM,SAAS,GAEX;QACF,MAAM,EAAE,eAAe;QACvB,QAAQ,EAAE,iBAAiB;QAC3B,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,iBAAiB;KAC5B,CAAC;IACF,OAAO;QACL;YACE,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,eAAe;SAC1B;QACD,GAAG,CAAC,GAAG,KAAK,CAAC,YAAY,GAAG,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC,IAAI,EAAE,CAAC;aACzD,GAAG,CAAC,CAAC,CAAC,EAAkB,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;aAC/D,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACd,IAAI;YACJ,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC;SAC1B,CAAC,CAAC;QACL;YACE,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,iBAAiB;SAC5B;KACO,CAAC;AACb,CAAC,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,37 @@
1
1
  {
2
2
  "name": "@jikan0/test-utils",
3
- "version": "1.2.0",
4
- "dependencies": {
5
- "tslib": "^2.3.0"
3
+ "version": "2.0.0",
4
+ "type": "commonjs",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
6
12
  },
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "license": "MIT",
19
+ "sideEffects": false,
7
20
  "publishConfig": {
8
- "access": "public"
21
+ "access": "public",
22
+ "registry": "https://registry.npmjs.org/"
9
23
  },
10
- "type": "commonjs",
11
- "main": "./src/index.js",
12
- "typings": "./src/index.d.ts"
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/dearlordylord/jikan.git",
27
+ "directory": "test-utils"
28
+ },
29
+ "scripts": {
30
+ "build": "node ../tools/build-package.cjs",
31
+ "prepack": "cd .. && npx turbo run build --filter=@jikan0/test-utils..."
32
+ },
33
+ "engines": {
34
+ "node": ">=24"
35
+ },
36
+ "dependencies": {}
13
37
  }
package/.eslintrc.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "extends": ["../.eslintrc.json"],
3
- "ignorePatterns": ["!**/*"],
4
- "overrides": [
5
- {
6
- "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
- "rules": {}
8
- },
9
- {
10
- "files": ["*.ts", "*.tsx"],
11
- "rules": {}
12
- },
13
- {
14
- "files": ["*.js", "*.jsx"],
15
- "rules": {}
16
- },
17
- {
18
- "files": ["*.json"],
19
- "parser": "jsonc-eslint-parser",
20
- "rules": {
21
- "@nx/dependency-checks": "error"
22
- }
23
- }
24
- ]
25
- }
package/jest.config.ts DELETED
@@ -1,11 +0,0 @@
1
- /* eslint-disable */
2
- export default {
3
- displayName: 'test-utils',
4
- preset: '../jest.preset.js',
5
- testEnvironment: 'node',
6
- transform: {
7
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8
- },
9
- moduleFileExtensions: ['ts', 'js', 'html'],
10
- coverageDirectory: '../coverage/test-utils',
11
- };
package/project.json DELETED
@@ -1,30 +0,0 @@
1
- {
2
- "name": "test-utils",
3
- "$schema": "../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "test-utils/src",
5
- "projectType": "library",
6
- "targets": {
7
- "build": {
8
- "executor": "@nx/js:tsc",
9
- "outputs": ["{options.outputPath}"],
10
- "options": {
11
- "outputPath": "dist/test-utils",
12
- "main": "test-utils/src/index.ts",
13
- "tsConfig": "test-utils/tsconfig.lib.json",
14
- "assets": ["test-utils/*.md"]
15
- }
16
- },
17
- "lint": {
18
- "executor": "@nx/eslint:lint",
19
- "outputs": ["{options.outputFile}"]
20
- },
21
- "test": {
22
- "executor": "@nx/jest:jest",
23
- "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
24
- "options": {
25
- "jestConfig": "test-utils/jest.config.ts"
26
- }
27
- }
28
- },
29
- "tags": []
30
- }
@@ -1,34 +0,0 @@
1
- export const BASIC_EXERCISE_PROGRAM = (() => {
2
- const ROUND_TYPES = ['warmup', 'exercise', 'rest', 'cooldown'] as const;
3
- type RoundType = (typeof ROUND_TYPES)[number];
4
- const ONE_MINUTE = 60 * 1000;
5
- const TOTAL_ROUNDS = 10;
6
- const WARMUP_DURATION = 5 * ONE_MINUTE;
7
- const EXERCISE_DURATION = 3 * ONE_MINUTE;
8
- // noinspection PointlessArithmeticExpressionJS
9
- const REST_DURATION = 1 * ONE_MINUTE;
10
- const COOLDOWN_DURATION = 5 * ONE_MINUTE;
11
- const DURATIONS: {
12
- [K in RoundType]: number;
13
- } = {
14
- warmup: WARMUP_DURATION,
15
- exercise: EXERCISE_DURATION,
16
- rest: REST_DURATION,
17
- cooldown: COOLDOWN_DURATION,
18
- };
19
- return [...Array(TOTAL_ROUNDS + 2 /*warmup/cooldown*/).keys()]
20
- .map(
21
- (i): RoundType =>
22
- i === 0
23
- ? 'warmup'
24
- : i === TOTAL_ROUNDS + 1
25
- ? 'cooldown'
26
- : i % 2 === 1
27
- ? 'exercise'
28
- : 'rest'
29
- )
30
- .map((kind) => ({
31
- kind,
32
- duration: DURATIONS[kind],
33
- }));
34
- })();
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "extends": "../tsconfig.base.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "forceConsistentCasingInFileNames": true,
6
- "strict": true,
7
- "noImplicitOverride": true,
8
- "noPropertyAccessFromIndexSignature": true,
9
- "noImplicitReturns": true,
10
- "noFallthroughCasesInSwitch": true
11
- },
12
- "files": [],
13
- "include": [],
14
- "references": [
15
- {
16
- "path": "./tsconfig.lib.json"
17
- },
18
- {
19
- "path": "./tsconfig.spec.json"
20
- }
21
- ]
22
- }
package/tsconfig.lib.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../dist/out-tsc",
5
- "declaration": true,
6
- "types": ["node"]
7
- },
8
- "include": ["src/**/*.ts"],
9
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10
- }
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": ["jest", "node"]
7
- },
8
- "include": [
9
- "jest.config.ts",
10
- "src/**/*.test.ts",
11
- "src/**/*.spec.ts",
12
- "src/**/*.d.ts"
13
- ]
14
- }
File without changes