Skip to content

Commit

Permalink
test: store unit test suites as siblings
Browse files Browse the repository at this point in the history
  • Loading branch information
kherock committed Nov 21, 2021
1 parent fdc0ac1 commit a5a4370
Show file tree
Hide file tree
Showing 34 changed files with 96 additions and 93 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}-
Expand All @@ -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 }}-
Expand Down
2 changes: 1 addition & 1 deletion api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
*/
// "tsconfigFilePath": "<projectFolder>/tsconfig.json",
"tsconfigFilePath": "<projectFolder>/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:
Expand Down
2 changes: 1 addition & 1 deletion jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
4 changes: 2 additions & 2 deletions test/unit/JsonService.test.ts → src/JsonService.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
18 changes: 9 additions & 9 deletions test/unit/OidcClient.test.ts → src/OidcClient.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/SigninState.test.ts → src/SigninState.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
8 changes: 4 additions & 4 deletions test/unit/State.test.ts → src/State.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 6 additions & 6 deletions test/unit/UserManager.test.ts → src/UserManager.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PopupWindow } from "../../src/navigators/PopupWindow";
import { PopupWindow } from "./PopupWindow";

describe("PopupWindow", () => {
let popupFromWindowOpen: WindowProxy;
Expand Down Expand Up @@ -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");
});

Expand All @@ -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");
});
});
Original file line number Diff line number Diff line change
@@ -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}$/;

Expand Down
2 changes: 1 addition & 1 deletion test/unit/utils/Event.test.ts → src/utils/Event.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
2 changes: 1 addition & 1 deletion test/unit/utils/Log.test.ts → src/utils/Log.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PopupUtils } from "../../../src/utils";
import { PopupUtils } from "./PopupUtils";

describe("PopupUtils", () => {
describe("center", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/utils/Timer.test.ts → src/utils/Timer.test.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {

Expand Down
9 changes: 0 additions & 9 deletions test/unit/tsconfig.json

This file was deleted.

Loading

0 comments on commit a5a4370

Please sign in to comment.