From a5a4370fc2dbdacf2d73596367c3b97c942381cd Mon Sep 17 00:00:00 2001 From: Kyle Herock Date: Sat, 20 Nov 2021 16:41:21 -0500 Subject: [PATCH] test: store unit test suites as siblings --- .eslintrc.yml | 5 ++++- .github/workflows/ci.yml | 4 ++-- api-extractor.json | 2 +- jest.config.mjs | 2 +- package.json | 6 +++--- {test/unit => src}/AccessTokenEvents.test.ts | 6 +++--- {test/unit => src}/ErrorResponse.test.ts | 2 +- {test/unit => src}/JsonService.test.ts | 4 ++-- {test/unit => src}/MetadataService.test.ts | 6 +++--- {test/unit => src}/OidcClient.test.ts | 18 +++++++++--------- {test/unit => src}/OidcClientSettings.test.ts | 6 +++--- {test/unit => src}/ResponseValidator.test.ts | 16 ++++++++-------- {test/unit => src}/SigninRequest.test.ts | 2 +- {test/unit => src}/SigninResponse.test.ts | 4 ++-- {test/unit => src}/SigninState.test.ts | 4 ++-- {test/unit => src}/SignoutRequest.test.ts | 2 +- {test/unit => src}/SignoutResponse.test.ts | 2 +- {test/unit => src}/State.test.ts | 8 ++++---- {test/unit => src}/UserInfoService.test.ts | 8 ++++---- {test/unit => src}/UserManager.test.ts | 12 ++++++------ {test/unit => src}/UserManagerEvents.test.ts | 4 ++-- {test/unit => src}/UserManagerSettings.test.ts | 6 +++--- .../unit => src}/WebStorageStateStore.test.ts | 4 ++-- .../navigators}/PopupWindow.test.ts | 4 +--- {test/unit => src}/utils/CryptoUtils.test.ts | 2 +- {test/unit => src}/utils/Event.test.ts | 2 +- {test/unit => src}/utils/JwtUtils.test.ts | 3 ++- {test/unit => src}/utils/Log.test.ts | 2 +- {test/unit => src}/utils/PopupUtils.test.ts | 2 +- {test/unit => src}/utils/Timer.test.ts | 2 +- {test/unit => src}/utils/UrlUtils.test.ts | 2 +- test/unit/tsconfig.json | 9 --------- tsconfig.build.json | 15 +++++++++++++++ tsconfig.json | 13 ++++--------- 34 files changed, 96 insertions(+), 93 deletions(-) rename {test/unit => src}/AccessTokenEvents.test.ts (96%) rename {test/unit => src}/ErrorResponse.test.ts (97%) rename {test/unit => src}/JsonService.test.ts (99%) rename {test/unit => src}/MetadataService.test.ts (99%) rename {test/unit => src}/OidcClient.test.ts (97%) rename {test/unit => src}/OidcClientSettings.test.ts (98%) rename {test/unit => src}/ResponseValidator.test.ts (97%) rename {test/unit => src}/SigninRequest.test.ts (99%) rename {test/unit => src}/SigninResponse.test.ts (98%) rename {test/unit => src}/SigninState.test.ts (98%) rename {test/unit => src}/SignoutRequest.test.ts (97%) rename {test/unit => src}/SignoutResponse.test.ts (95%) rename {test/unit => src}/State.test.ts (95%) rename {test/unit => src}/UserInfoService.test.ts (92%) rename {test/unit => src}/UserManager.test.ts (94%) rename {test/unit => src}/UserManagerEvents.test.ts (92%) rename {test/unit => src}/UserManagerSettings.test.ts (98%) rename {test/unit => src}/WebStorageStateStore.test.ts (97%) rename {test/unit => src/navigators}/PopupWindow.test.ts (87%) rename {test/unit => src}/utils/CryptoUtils.test.ts (88%) rename {test/unit => src}/utils/Event.test.ts (98%) rename {test/unit => src}/utils/JwtUtils.test.ts (97%) rename {test/unit => src}/utils/Log.test.ts (98%) rename {test/unit => src}/utils/PopupUtils.test.ts (97%) rename {test/unit => src}/utils/Timer.test.ts (99%) rename {test/unit => src}/utils/UrlUtils.test.ts (95%) delete mode 100644 test/unit/tsconfig.json create mode 100644 tsconfig.build.json diff --git a/.eslintrc.yml b/.eslintrc.yml index 218bef59f..510f92cc9 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -56,6 +56,9 @@ overrides: - files: src/**/* env: node: false - - files: test/**/* + - files: [src/**/*.test.*, test/**/*] env: jest: true + rules: + "@typescript-eslint/unbound-method": "off" + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a38e3659b..a87f715e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: with: path: | lib/ - tsconfig.tsbuildinfo + tsconfig.build.tsbuildinfo key: build-${{ github.head_ref }}-${{ github.sha }} restore-keys: | build-${{ github.head_ref }}- @@ -47,7 +47,7 @@ jobs: with: path: | .eslintcache - test/unit/tsconfig.tsbuildinfo + tsconfig.tsbuildinfo key: test-${{ github.head_ref }}-${{ github.sha }} restore-keys: | test-${{ github.head_ref }}- diff --git a/api-extractor.json b/api-extractor.json index 98587f5d9..e2d26f675 100644 --- a/api-extractor.json +++ b/api-extractor.json @@ -77,7 +77,7 @@ * SUPPORTED TOKENS: , , * DEFAULT VALUE: "/tsconfig.json" */ - // "tsconfigFilePath": "/tsconfig.json", + "tsconfigFilePath": "/tsconfig.build.json" /** * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk. * The object must conform to the TypeScript tsconfig schema: diff --git a/jest.config.mjs b/jest.config.mjs index 81468a001..dbd45cb4e 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -5,7 +5,7 @@ const collectCoverage = yn(process.env.CI); export default { preset: "ts-jest", clearMocks: true, - testMatch: ["**/test/unit/**/*.test.ts"], + testMatch: ["**/{src,test}/**/*.test.ts"], testEnvironment: "jsdom", collectCoverage, coverageReporters: collectCoverage ? ["lcov"] : ["lcov", "text"], diff --git a/package.json b/package.json index d29fc972e..168e63f0a 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,10 @@ ], "scripts": { "build": "node scripts/build.js && npm run build-types", - "build-types": "tsc --emitDeclarationOnly && api-extractor run", - "clean": "git clean -fdX dist", + "build-types": "tsc -p tsconfig.build.json && api-extractor run", + "clean": "git clean -fdX dist lib *.tsbuildinfo", "prepack": "npm run build", - "test": "tsc -p test/unit/tsconfig.json && jest", + "test": "tsc && jest", "typedoc": "typedoc", "lint": "eslint --max-warnings=0 --cache .", "prepare": "husky install" diff --git a/test/unit/AccessTokenEvents.test.ts b/src/AccessTokenEvents.test.ts similarity index 96% rename from test/unit/AccessTokenEvents.test.ts rename to src/AccessTokenEvents.test.ts index 838e491f8..99a5306d9 100644 --- a/test/unit/AccessTokenEvents.test.ts +++ b/src/AccessTokenEvents.test.ts @@ -1,9 +1,9 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Timer } from "../../src/utils"; -import { AccessTokenEvents } from "../../src/AccessTokenEvents"; -import type { User } from "../../src/User"; +import { Timer } from "./utils"; +import { AccessTokenEvents } from "./AccessTokenEvents"; +import type { User } from "./User"; describe("AccessTokenEvents", () => { diff --git a/test/unit/ErrorResponse.test.ts b/src/ErrorResponse.test.ts similarity index 97% rename from test/unit/ErrorResponse.test.ts rename to src/ErrorResponse.test.ts index dbba3fd22..200c65215 100644 --- a/test/unit/ErrorResponse.test.ts +++ b/src/ErrorResponse.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { ErrorResponse } from "../../src/ErrorResponse"; +import { ErrorResponse } from "./ErrorResponse"; describe("ErrorResponse", () => { diff --git a/test/unit/JsonService.test.ts b/src/JsonService.test.ts similarity index 99% rename from test/unit/JsonService.test.ts rename to src/JsonService.test.ts index cd0cdad38..b0fbda1ad 100644 --- a/test/unit/JsonService.test.ts +++ b/src/JsonService.test.ts @@ -1,8 +1,8 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { JsonService } from "../../src/JsonService"; +import { Log } from "./utils"; +import { JsonService } from "./JsonService"; import { mocked } from "ts-jest/utils"; describe("JsonService", () => { diff --git a/test/unit/MetadataService.test.ts b/src/MetadataService.test.ts similarity index 99% rename from test/unit/MetadataService.test.ts rename to src/MetadataService.test.ts index 5f8414cf2..1a119d495 100644 --- a/test/unit/MetadataService.test.ts +++ b/src/MetadataService.test.ts @@ -1,9 +1,9 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { MetadataService } from "../../src/MetadataService"; -import { OidcClientSettings, OidcClientSettingsStore } from "../../src/OidcClientSettings"; +import { Log } from "./utils"; +import { MetadataService } from "./MetadataService"; +import { OidcClientSettings, OidcClientSettingsStore } from "./OidcClientSettings"; describe("MetadataService", () => { let settings: OidcClientSettings; diff --git a/test/unit/OidcClient.test.ts b/src/OidcClient.test.ts similarity index 97% rename from test/unit/OidcClient.test.ts rename to src/OidcClient.test.ts index 41d04209f..12a5aafcf 100644 --- a/test/unit/OidcClient.test.ts +++ b/src/OidcClient.test.ts @@ -1,15 +1,15 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { OidcClient } from "../../src/OidcClient"; -import { OidcClientSettings, OidcClientSettingsStore } from "../../src/OidcClientSettings"; -import { SigninState } from "../../src/SigninState"; -import { State } from "../../src/State"; -import { SigninRequest } from "../../src/SigninRequest"; -import { SignoutRequest } from "../../src/SignoutRequest"; -import { SignoutResponse } from "../../src/SignoutResponse"; -import type { ErrorResponse } from "../../src/ErrorResponse"; +import { Log } from "./utils"; +import { OidcClient } from "./OidcClient"; +import { OidcClientSettings, OidcClientSettingsStore } from "./OidcClientSettings"; +import { SigninState } from "./SigninState"; +import { State } from "./State"; +import { SigninRequest } from "./SigninRequest"; +import { SignoutRequest } from "./SignoutRequest"; +import { SignoutResponse } from "./SignoutResponse"; +import type { ErrorResponse } from "./ErrorResponse"; describe("OidcClient", () => { let subject: OidcClient; diff --git a/test/unit/OidcClientSettings.test.ts b/src/OidcClientSettings.test.ts similarity index 98% rename from test/unit/OidcClientSettings.test.ts rename to src/OidcClientSettings.test.ts index b63cfbb7b..39dca9629 100644 --- a/test/unit/OidcClientSettings.test.ts +++ b/src/OidcClientSettings.test.ts @@ -1,9 +1,9 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { OidcClientSettingsStore } from "../../src/OidcClientSettings"; -import type { StateStore } from "../../src/StateStore"; +import { Log } from "./utils"; +import { OidcClientSettingsStore } from "./OidcClientSettings"; +import type { StateStore } from "./StateStore"; describe("OidcClientSettings", () => { diff --git a/test/unit/ResponseValidator.test.ts b/src/ResponseValidator.test.ts similarity index 97% rename from test/unit/ResponseValidator.test.ts rename to src/ResponseValidator.test.ts index 49dbfa4f1..9dfc694f1 100644 --- a/test/unit/ResponseValidator.test.ts +++ b/src/ResponseValidator.test.ts @@ -1,14 +1,14 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { ResponseValidator } from "../../src/ResponseValidator"; -import { MetadataService } from "../../src/MetadataService"; -import type { UserInfoService } from "../../src/UserInfoService"; -import { SigninState } from "../../src/SigninState"; -import type { SigninResponse } from "../../src/SigninResponse"; -import type { ErrorResponse } from "../../src/ErrorResponse"; -import type { UserProfile } from "../../src/User"; +import { Log } from "./utils"; +import { ResponseValidator } from "./ResponseValidator"; +import { MetadataService } from "./MetadataService"; +import type { UserInfoService } from "./UserInfoService"; +import { SigninState } from "./SigninState"; +import type { SigninResponse } from "./SigninResponse"; +import type { ErrorResponse } from "./ErrorResponse"; +import type { UserProfile } from "./User"; // access private methods class ResponseValidatorWrapper extends ResponseValidator { diff --git a/test/unit/SigninRequest.test.ts b/src/SigninRequest.test.ts similarity index 99% rename from test/unit/SigninRequest.test.ts rename to src/SigninRequest.test.ts index 3dd99f738..6996cf7e1 100644 --- a/test/unit/SigninRequest.test.ts +++ b/src/SigninRequest.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { SigninRequest } from "../../src/SigninRequest"; +import { SigninRequest } from "./SigninRequest"; describe("SigninRequest", () => { diff --git a/test/unit/SigninResponse.test.ts b/src/SigninResponse.test.ts similarity index 98% rename from test/unit/SigninResponse.test.ts rename to src/SigninResponse.test.ts index b5d357f7a..60cc6a8b6 100644 --- a/test/unit/SigninResponse.test.ts +++ b/src/SigninResponse.test.ts @@ -1,8 +1,8 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { SigninResponse } from "../../src/SigninResponse"; -import { Timer } from "../../src/utils"; +import { SigninResponse } from "./SigninResponse"; +import { Timer } from "./utils"; describe("SigninResponse", () => { describe("constructor", () => { diff --git a/test/unit/SigninState.test.ts b/src/SigninState.test.ts similarity index 98% rename from test/unit/SigninState.test.ts rename to src/SigninState.test.ts index e5707dcd6..81adad9d3 100644 --- a/test/unit/SigninState.test.ts +++ b/src/SigninState.test.ts @@ -1,8 +1,8 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { SigninState } from "../../src/SigninState"; +import { Log } from "./utils"; +import { SigninState } from "./SigninState"; describe("SigninState", () => { diff --git a/test/unit/SignoutRequest.test.ts b/src/SignoutRequest.test.ts similarity index 97% rename from test/unit/SignoutRequest.test.ts rename to src/SignoutRequest.test.ts index a8eef281e..fb02f89b1 100644 --- a/test/unit/SignoutRequest.test.ts +++ b/src/SignoutRequest.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { SignoutRequest, SignoutRequestArgs } from "../../src/SignoutRequest"; +import { SignoutRequest, SignoutRequestArgs } from "./SignoutRequest"; describe("SignoutRequest", () => { diff --git a/test/unit/SignoutResponse.test.ts b/src/SignoutResponse.test.ts similarity index 95% rename from test/unit/SignoutResponse.test.ts rename to src/SignoutResponse.test.ts index 4047f5186..1d0c4c3cb 100644 --- a/test/unit/SignoutResponse.test.ts +++ b/src/SignoutResponse.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { SignoutResponse } from "../../src/SignoutResponse"; +import { SignoutResponse } from "./SignoutResponse"; describe("SignoutResponse", () => { diff --git a/test/unit/State.test.ts b/src/State.test.ts similarity index 95% rename from test/unit/State.test.ts rename to src/State.test.ts index 0171a6519..f454b6bd5 100644 --- a/test/unit/State.test.ts +++ b/src/State.test.ts @@ -1,11 +1,11 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { State } from "../../src/State"; +import { Log } from "./utils"; +import { State } from "./State"; -import { InMemoryWebStorage } from "../../src/InMemoryWebStorage"; -import { WebStorageStateStore } from "../../src/WebStorageStateStore"; +import { InMemoryWebStorage } from "./InMemoryWebStorage"; +import { WebStorageStateStore } from "./WebStorageStateStore"; describe("State", () => { diff --git a/test/unit/UserInfoService.test.ts b/src/UserInfoService.test.ts similarity index 92% rename from test/unit/UserInfoService.test.ts rename to src/UserInfoService.test.ts index cf065738b..8e87fb12d 100644 --- a/test/unit/UserInfoService.test.ts +++ b/src/UserInfoService.test.ts @@ -1,10 +1,10 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { UserInfoService } from "../../src/UserInfoService"; -import { MetadataService } from "../../src/MetadataService"; -import type { JsonService } from "../../src/JsonService"; -import { OidcClientSettingsStore } from "../../src/OidcClientSettings"; +import { UserInfoService } from "./UserInfoService"; +import { MetadataService } from "./MetadataService"; +import type { JsonService } from "./JsonService"; +import { OidcClientSettingsStore } from "./OidcClientSettings"; describe("UserInfoService", () => { let subject: UserInfoService; diff --git a/test/unit/UserManager.test.ts b/src/UserManager.test.ts similarity index 94% rename from test/unit/UserManager.test.ts rename to src/UserManager.test.ts index 20249bc50..999e42821 100644 --- a/test/unit/UserManager.test.ts +++ b/src/UserManager.test.ts @@ -1,14 +1,14 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log, Logger } from "../../src/utils"; -import { UserManager } from "../../src/UserManager"; -import { UserManagerSettings, UserManagerSettingsStore } from "../../src/UserManagerSettings"; -import { User } from "../../src/User"; -import { WebStorageStateStore } from "../../src/WebStorageStateStore"; +import { Log, Logger } from "./utils"; +import { UserManager } from "./UserManager"; +import { UserManagerSettings, UserManagerSettingsStore } from "./UserManagerSettings"; +import { User } from "./User"; +import { WebStorageStateStore } from "./WebStorageStateStore"; import { mocked } from "ts-jest/utils"; -import type { IWindow } from "../../src/navigators"; +import type { IWindow } from "./navigators"; describe("UserManager", () => { let settings: UserManagerSettings; diff --git a/test/unit/UserManagerEvents.test.ts b/src/UserManagerEvents.test.ts similarity index 92% rename from test/unit/UserManagerEvents.test.ts rename to src/UserManagerEvents.test.ts index 2c93f65ec..00c2f25fa 100644 --- a/test/unit/UserManagerEvents.test.ts +++ b/src/UserManagerEvents.test.ts @@ -1,8 +1,8 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { UserManagerEvents } from "../../src/UserManagerEvents"; -import { UserManagerSettingsStore } from "../../src/UserManagerSettings"; +import { UserManagerEvents } from "./UserManagerEvents"; +import { UserManagerSettingsStore } from "./UserManagerSettings"; describe("UserManagerEvents", () => { diff --git a/test/unit/UserManagerSettings.test.ts b/src/UserManagerSettings.test.ts similarity index 98% rename from test/unit/UserManagerSettings.test.ts rename to src/UserManagerSettings.test.ts index f9f324ca6..e41630a1e 100644 --- a/test/unit/UserManagerSettings.test.ts +++ b/src/UserManagerSettings.test.ts @@ -1,9 +1,9 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log } from "../../src/utils"; -import { UserManagerSettingsStore } from "../../src/UserManagerSettings"; -import type { WebStorageStateStore } from "../../src/WebStorageStateStore"; +import { Log } from "./utils"; +import { UserManagerSettingsStore } from "./UserManagerSettings"; +import type { WebStorageStateStore } from "./WebStorageStateStore"; describe("UserManagerSettings", () => { diff --git a/test/unit/WebStorageStateStore.test.ts b/src/WebStorageStateStore.test.ts similarity index 97% rename from test/unit/WebStorageStateStore.test.ts rename to src/WebStorageStateStore.test.ts index 108f77a50..ae10d0a41 100644 --- a/test/unit/WebStorageStateStore.test.ts +++ b/src/WebStorageStateStore.test.ts @@ -1,8 +1,8 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { WebStorageStateStore } from "../../src/WebStorageStateStore"; -import { InMemoryWebStorage } from "../../src/InMemoryWebStorage"; +import { WebStorageStateStore } from "./WebStorageStateStore"; +import { InMemoryWebStorage } from "./InMemoryWebStorage"; describe("WebStorageStateStore", () => { let prefix: string; diff --git a/test/unit/PopupWindow.test.ts b/src/navigators/PopupWindow.test.ts similarity index 87% rename from test/unit/PopupWindow.test.ts rename to src/navigators/PopupWindow.test.ts index bdb0cdfe6..701ced747 100644 --- a/test/unit/PopupWindow.test.ts +++ b/src/navigators/PopupWindow.test.ts @@ -1,4 +1,4 @@ -import { PopupWindow } from "../../src/navigators/PopupWindow"; +import { PopupWindow } from "./PopupWindow"; describe("PopupWindow", () => { let popupFromWindowOpen: WindowProxy; @@ -41,7 +41,6 @@ describe("PopupWindow", () => { })); await expect(promise).resolves.toHaveProperty("url", "http://app/cb?state=someid"); - // eslint-disable-next-line @typescript-eslint/unbound-method expect(popupFromWindowOpen.location.replace).toHaveBeenCalledWith("http://sts/authorize?x=y"); }); @@ -56,7 +55,6 @@ describe("PopupWindow", () => { })); await expect(promise).rejects.toThrow("Invalid response from window"); - // eslint-disable-next-line @typescript-eslint/unbound-method expect(popupFromWindowOpen.location.replace).toHaveBeenCalledWith("http://sts/authorize?x=y"); }); }); diff --git a/test/unit/utils/CryptoUtils.test.ts b/src/utils/CryptoUtils.test.ts similarity index 88% rename from test/unit/utils/CryptoUtils.test.ts rename to src/utils/CryptoUtils.test.ts index dfd9bdbc5..d78f747d2 100644 --- a/test/unit/utils/CryptoUtils.test.ts +++ b/src/utils/CryptoUtils.test.ts @@ -1,4 +1,4 @@ -import { CryptoUtils } from "../../../src/utils"; +import { CryptoUtils } from "./CryptoUtils"; const pattern = /^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/; diff --git a/test/unit/utils/Event.test.ts b/src/utils/Event.test.ts similarity index 98% rename from test/unit/utils/Event.test.ts rename to src/utils/Event.test.ts index 4751e7d98..6d1de0940 100644 --- a/test/unit/utils/Event.test.ts +++ b/src/utils/Event.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Event } from "../../../src/utils"; +import { Event } from "./Event"; describe("Event", () => { diff --git a/test/unit/utils/JwtUtils.test.ts b/src/utils/JwtUtils.test.ts similarity index 97% rename from test/unit/utils/JwtUtils.test.ts rename to src/utils/JwtUtils.test.ts index 320abe9fb..6f382c79b 100644 --- a/test/unit/utils/JwtUtils.test.ts +++ b/src/utils/JwtUtils.test.ts @@ -1,7 +1,8 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log, JwtUtils } from "../../../src/utils"; +import { JwtUtils } from "./JwtUtils"; +import { Log } from "./Log"; describe("JwtUtils", () => { diff --git a/test/unit/utils/Log.test.ts b/src/utils/Log.test.ts similarity index 98% rename from test/unit/utils/Log.test.ts rename to src/utils/Log.test.ts index d73c84e0a..07285a8ca 100644 --- a/test/unit/utils/Log.test.ts +++ b/src/utils/Log.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { Log, ILogger, Logger } from "../../../src/utils"; +import { Log, ILogger, Logger } from "./Log"; describe("Log", () => { let subject: Logger; diff --git a/test/unit/utils/PopupUtils.test.ts b/src/utils/PopupUtils.test.ts similarity index 97% rename from test/unit/utils/PopupUtils.test.ts rename to src/utils/PopupUtils.test.ts index 0a1b5e372..fee781bcb 100644 --- a/test/unit/utils/PopupUtils.test.ts +++ b/src/utils/PopupUtils.test.ts @@ -1,4 +1,4 @@ -import { PopupUtils } from "../../../src/utils"; +import { PopupUtils } from "./PopupUtils"; describe("PopupUtils", () => { describe("center", () => { diff --git a/test/unit/utils/Timer.test.ts b/src/utils/Timer.test.ts similarity index 99% rename from test/unit/utils/Timer.test.ts rename to src/utils/Timer.test.ts index f43bf77e3..c58bea64e 100644 --- a/test/unit/utils/Timer.test.ts +++ b/src/utils/Timer.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { IntervalTimer, Timer } from "../../../src/utils"; +import { IntervalTimer, Timer } from "./Timer"; class IntervalTimerMock implements IntervalTimer { callback: ((...args: any[]) => void); diff --git a/test/unit/utils/UrlUtils.test.ts b/src/utils/UrlUtils.test.ts similarity index 95% rename from test/unit/utils/UrlUtils.test.ts rename to src/utils/UrlUtils.test.ts index 726a28c30..27d73b653 100644 --- a/test/unit/utils/UrlUtils.test.ts +++ b/src/utils/UrlUtils.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -import { UrlUtils } from "../../../src/utils"; +import { UrlUtils } from "./UrlUtils"; describe("UrlUtils", () => { diff --git a/test/unit/tsconfig.json b/test/unit/tsconfig.json deleted file mode 100644 index 8dd3ea314..000000000 --- a/test/unit/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "rootDir": "../..", - "noEmit": true, - "tsBuildInfoFile": "tsconfig.tsbuildinfo" - }, - "include": ["."] -} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 000000000..f3b0bdccc --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + // match output dir to input dir. e.g. dist/index instead of dist/src/index + "rootDir": "./src", + "outDir": "./lib", + // output .d.ts declaration files for consumers + "declaration": true, + "declarationMap": true, + "noEmit": false, + "emitDeclarationOnly": true, + "tsBuildInfoFile": "tsconfig.build.tsbuildinfo" + }, + "files": ["src/index.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 0db4255a4..5b3264a31 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,13 @@ { // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs - "include": ["src", "types"], "compilerOptions": { "target": "ES2019", "module": "ESNext", "moduleResolution": "node", "lib": ["ES2019", "DOM", "DOM.Iterable"], "incremental": true, + "noEmit": true, "tsBuildInfoFile": "tsconfig.tsbuildinfo", - // output .d.ts declaration files for consumers - "declaration": true, - "declarationMap": true, - // match output dir to input dir. e.g. dist/index instead of dist/src/index - "rootDir": "./src", - "outDir": "./lib", // stricter type-checking for stronger correctness. Recommended by TS "strict": true, // interop between ESM and CJS modules. Recommended by TS @@ -24,7 +18,8 @@ "forceConsistentCasingInFileNames": true, // ensure type imports are side-effect free by enforcing that `import type` is used "importsNotUsedAsValues": "error", - // prevent the use features that do not work with isolated transpilation + // prevent the use of features that are incompatible with isolated transpilation "isolatedModules": true, - } + }, + "include": ["src/"], }