diff --git a/.nycrc b/.nycrc index 51521c5fdfe..f20c0296dde 100644 --- a/.nycrc +++ b/.nycrc @@ -13,6 +13,7 @@ "packages/testing/**", "packages/**/ExpressRouter.ts", "packages/**/RouteService.ts", + "packages/core", "packages/platform/platform-test-utils", "packages/platform/platform-serverless", "packages/platform/platform-serverless-http", diff --git a/package.json b/package.json index e2f11932274..aee56b9c77f 100644 --- a/package.json +++ b/package.json @@ -94,13 +94,14 @@ "@tsed/logger": ">=6.0.2", "ajv": "8.9.0", "axios": "0.21.1", + "barrelsby": "^2.3.2", "change-case": "4.1.2", "globby": "11.0.3", "lerna": "4.0.0", "microbundle": "0.13.0", + "rxjs": "^6.5.2", "source-map-support": "0.5.19", - "uuid": "8.3.2", - "rxjs": "^6.5.2" + "uuid": "8.3.2" }, "devDependencies": { "@commitlint/cli": "^16.1.0", diff --git a/packages/core/jest.config.js b/packages/core/jest.config.js new file mode 100644 index 00000000000..f2fb9dd9e51 --- /dev/null +++ b/packages/core/jest.config.js @@ -0,0 +1,14 @@ +// For a detailed explanation regarding each configuration property, visit: +// https://jestjs.io/docs/en/configuration.html + +module.exports = { + ...require("@tsed/jest-config")(__dirname, "core"), + coverageThreshold: { + global: { + statements: 97.95, + branches: 89.65, + functions: 96.04, + lines: 98.17 + } + } +}; diff --git a/packages/core/package.json b/packages/core/package.json index 8df479df0cf..e8dc34de138 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -5,6 +5,7 @@ "private": false, "source": "./src/index.ts", "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", "typings": "./lib/types/index.d.ts", "exports": { "types": "./lib/types/index.d.ts", @@ -13,9 +14,11 @@ "default": "./lib/esm/index.js" }, "scripts": { - "build": "yarn run build:esm && yarn run build:cjs", + "build": "yarn barrels && yarn run build:esm && yarn run build:cjs", + "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\"", "build:cjs": "tsc --build tsconfig.compile.json", - "build:esm": "tsc --build tsconfig.compile.esm.json" + "build:esm": "tsc --build tsconfig.compile.esm.json", + "test": "cross-env NODE_ENV=test yarn jest --max-workers=2" }, "dependencies": { "reflect-metadata": "^0.1.13", diff --git a/packages/core/src/decorators/configurable.spec.ts b/packages/core/src/decorators/configurable.spec.ts index d49b6b82dcb..5ee251a89b3 100644 --- a/packages/core/src/decorators/configurable.spec.ts +++ b/packages/core/src/decorators/configurable.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {Configurable, descriptorOf, NotConfigurable} from "../../src"; class Test { @@ -8,11 +7,11 @@ class Test { describe("Configurable", () => { it("should set attribut as configurable", () => { Configurable()(Test, "test"); - expect(descriptorOf(Test, "test").configurable).to.eq(true); + expect(descriptorOf(Test, "test").configurable).toBe(true); }); it("should set attribut as not configurable", () => { NotConfigurable()(Test, "test"); - expect(descriptorOf(Test, "test").configurable).to.eq(false); + expect(descriptorOf(Test, "test").configurable).toBe(false); }); }); diff --git a/packages/core/src/decorators/configurable.ts b/packages/core/src/decorators/configurable.ts index a07c50c5928..2e78fc5b71f 100644 --- a/packages/core/src/decorators/configurable.ts +++ b/packages/core/src/decorators/configurable.ts @@ -1,9 +1,4 @@ -/** - * @module common/core - */ -import {descriptorOf} from "../utils"; - -/** */ +import {descriptorOf} from "../utils/objects/descriptorOf"; export function Configurable(value: boolean = true): Function { return (target: any, propertyKey: string) => { diff --git a/packages/core/src/decorators/deprecated.spec.ts b/packages/core/src/decorators/deprecated.spec.ts index 047e7fd1f24..178b129b8c9 100644 --- a/packages/core/src/decorators/deprecated.spec.ts +++ b/packages/core/src/decorators/deprecated.spec.ts @@ -1,12 +1,17 @@ -import {expect} from "chai"; -import {Deprecated} from "../../src"; +import {Deprecated} from "./deprecated"; +import {deprecate} from "util"; -class Test { - test() {} -} +jest.mock("util"); describe("Deprecated", () => { it("should wrap method as deprecated", () => { - expect(Deprecated("test")(Test, "test", {value: Test.prototype.test}).value).to.be.a("function"); + class Test { + @Deprecated("test") + test() {} + } + + new Test(); + + expect(deprecate).toHaveBeenCalledWith(expect.any(Function), "test"); }); }); diff --git a/packages/core/src/decorators/deprecated.ts b/packages/core/src/decorators/deprecated.ts index 4422004e1f2..9dd9ed04d68 100644 --- a/packages/core/src/decorators/deprecated.ts +++ b/packages/core/src/decorators/deprecated.ts @@ -1,5 +1,5 @@ -import {Type} from "../domain/Type"; import {deprecate} from "util"; +import {Type} from "../domain/Type"; /** * The `@Deprecated()` decorators wraps the given method in such a way that it is marked as deprecated. * diff --git a/packages/core/src/decorators/enumerable.spec.ts b/packages/core/src/decorators/enumerable.spec.ts index 6f05edb4b0f..79f256fb7cc 100644 --- a/packages/core/src/decorators/enumerable.spec.ts +++ b/packages/core/src/decorators/enumerable.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {Enumerable, getEnumerableKeys, NotEnumerable} from "../../src"; class Test1 { @@ -46,16 +45,16 @@ class Test2 extends Parent1 { describe("Enumerable", () => { it("should have some keys with Test1", () => { - expect(getEnumerableKeys(new Test1())).to.deep.eq(["test", "name"]); - expect(Object.keys(new Test1())).to.deep.eq(["test"]); - expect(Object.getOwnPropertyNames(new Test1())).to.deep.eq(["test"]); - expect(Reflect.ownKeys(new Test2())).to.deep.eq(["prop", "test", "_privateTest"]); + expect(getEnumerableKeys(new Test1())).toEqual(["test", "name"]); + expect(Object.keys(new Test1())).toEqual(["test"]); + expect(Object.getOwnPropertyNames(new Test1())).toEqual(["test"]); + expect(Reflect.ownKeys(new Test2())).toEqual(["prop", "test", "_privateTest"]); }); it("should have some keys with Test2", () => { - expect(getEnumerableKeys(new Test2())).to.deep.eq(["prop", "test", "first", "privateTest", "name", "parentProp"]); - expect(Object.keys(new Test2())).to.deep.eq(["prop", "test", "_privateTest"]); - expect(Object.getOwnPropertyNames(new Test2())).to.deep.eq(["prop", "test", "_privateTest"]); - expect(Reflect.ownKeys(new Test2())).to.deep.eq(["prop", "test", "_privateTest"]); + expect(getEnumerableKeys(new Test2())).toEqual(["prop", "test", "first", "privateTest", "name", "parentProp"]); + expect(Object.keys(new Test2())).toEqual(["prop", "test", "_privateTest"]); + expect(Object.getOwnPropertyNames(new Test2())).toEqual(["prop", "test", "_privateTest"]); + expect(Reflect.ownKeys(new Test2())).toEqual(["prop", "test", "_privateTest"]); }); }); diff --git a/packages/core/src/decorators/enumerable.ts b/packages/core/src/decorators/enumerable.ts index 55ebc7bf822..49df1bad15d 100644 --- a/packages/core/src/decorators/enumerable.ts +++ b/packages/core/src/decorators/enumerable.ts @@ -1,9 +1,4 @@ -/** - * @module common/core - */ -import {descriptorOf} from "../utils"; - -/** */ +import {descriptorOf} from "../utils/objects/descriptorOf"; export function Enumerable(value: boolean = true): Function { return (target: any, propertyKey: string) => { diff --git a/packages/core/src/decorators/index.ts b/packages/core/src/decorators/index.ts deleted file mode 100644 index a55215e872f..00000000000 --- a/packages/core/src/decorators/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @module common/core - */ -/** */ -export * from "./deprecated"; -export * from "./configurable"; -export * from "./enumerable"; -export * from "./writable"; -export * from "./readOnly"; -export * from "./notConfigurable"; -export * from "./notEnumerable"; -export * from "./storeSet"; -export * from "./storeMerge"; -export * from "./storeFn"; diff --git a/packages/core/src/decorators/notConfigurable.ts b/packages/core/src/decorators/notConfigurable.ts index cda2c661975..adacd1a45d9 100644 --- a/packages/core/src/decorators/notConfigurable.ts +++ b/packages/core/src/decorators/notConfigurable.ts @@ -1,8 +1,5 @@ -/** - * @module common/core - */ import {Configurable} from "./configurable"; -/** */ + export function NotConfigurable(): Function { return Configurable(false); } diff --git a/packages/core/src/decorators/notEnumerable.ts b/packages/core/src/decorators/notEnumerable.ts index f8ad64d023b..83a33f51470 100644 --- a/packages/core/src/decorators/notEnumerable.ts +++ b/packages/core/src/decorators/notEnumerable.ts @@ -1,8 +1,5 @@ -/** - * @module common/core - */ import {Enumerable} from "./enumerable"; -/** */ + export function NotEnumerable(): Function { return Enumerable(false); } diff --git a/packages/core/src/decorators/readOnly.ts b/packages/core/src/decorators/readOnly.ts index 913376e627e..4dbb2fab531 100644 --- a/packages/core/src/decorators/readOnly.ts +++ b/packages/core/src/decorators/readOnly.ts @@ -1,8 +1,5 @@ -/** - * @module common/core - */ import {Writable} from "./writable"; -/** */ + export function Readonly(): Function { return Writable(false); } diff --git a/packages/core/src/decorators/writable.spec.ts b/packages/core/src/decorators/writable.spec.ts index cb91e0dc8b4..50a2431dc85 100644 --- a/packages/core/src/decorators/writable.spec.ts +++ b/packages/core/src/decorators/writable.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {descriptorOf, Readonly, Writable} from "../../src"; class Test {} @@ -6,10 +5,10 @@ class Test {} describe("Writable", () => { it("should set attribut as writable", () => { Writable()(Test, "test"); - expect(descriptorOf(Test, "test").writable).to.eq(true); + expect(descriptorOf(Test, "test").writable).toBe(true); }); it("should set attribut as readonly", () => { Readonly()(Test, "test"); - expect(descriptorOf(Test, "test").writable).to.eq(false); + expect(descriptorOf(Test, "test").writable).toBe(false); }); }); diff --git a/packages/core/src/decorators/writable.ts b/packages/core/src/decorators/writable.ts index 651e6a38f90..d678d750243 100644 --- a/packages/core/src/decorators/writable.ts +++ b/packages/core/src/decorators/writable.ts @@ -1,9 +1,4 @@ -/** - * @module common/core - */ -import {descriptorOf} from "../utils"; - -/** */ +import {descriptorOf} from "../utils/objects/descriptorOf"; export function Writable(value: boolean = true): Function { return (target: any, propertyKey: string) => { diff --git a/packages/core/src/domain/AnyToPromise.spec.ts b/packages/core/src/domain/AnyToPromise.spec.ts index 7c170eb017e..f8d7efe1140 100644 --- a/packages/core/src/domain/AnyToPromise.spec.ts +++ b/packages/core/src/domain/AnyToPromise.spec.ts @@ -1,5 +1,4 @@ import {catchAsyncError, isStream} from "@tsed/core"; -import {expect} from "chai"; import {createReadStream} from "fs"; import {of} from "rxjs"; import {AnyToPromise, AnyToPromiseStatus} from "./AnyToPromise"; @@ -21,7 +20,7 @@ describe("AnyToPromise", () => { return "test"; }); - expect(result).to.deep.equal({state: "RESOLVED", data: "test", type: "DATA"}); + expect(result).toEqual({state: "RESOLVED", data: "test", type: "DATA"}); }); it("should handle async value", async () => { @@ -31,7 +30,7 @@ describe("AnyToPromise", () => { return "test"; }); - expect(result).to.deep.equal({state: "RESOLVED", data: "test", type: "DATA"}); + expect(result).toEqual({state: "RESOLVED", data: "test", type: "DATA"}); }); it("should handle canceled async value", async () => { const resolver = new AnyToPromise(); @@ -40,7 +39,7 @@ describe("AnyToPromise", () => { return AnyToPromiseStatus.CANCELED; }); - expect(result).to.deep.equal({state: "CANCELED"}); + expect(result).toEqual({state: "CANCELED"}); }); it("should handle response with data", async () => { const resolver = new AnyToPromise(); @@ -56,7 +55,7 @@ describe("AnyToPromise", () => { }; }); - expect(result).to.deep.equal({ + expect(result).toEqual({ state: "RESOLVED", data: "data", headers: { @@ -73,7 +72,7 @@ describe("AnyToPromise", () => { return undefined; }); - expect(result).to.deep.equal({state: "RESOLVED", data: undefined, type: "DATA"}); + expect(result).toEqual({state: "RESOLVED", data: undefined, type: "DATA"}); }); it("should handle observable", async () => { const resolver = new AnyToPromise(); @@ -82,7 +81,7 @@ describe("AnyToPromise", () => { return of("test"); }); - expect(result).to.deep.equal({state: "RESOLVED", data: "test", type: "DATA"}); + expect(result).toEqual({state: "RESOLVED", data: "test", type: "DATA"}); }); it("should handle buffer", async () => { const resolver = new AnyToPromise(); @@ -91,8 +90,8 @@ describe("AnyToPromise", () => { return Buffer.from("test"); }); - expect(Buffer.isBuffer(result.data)).to.equal(true); - expect(result.type).to.equal("BUFFER"); + expect(Buffer.isBuffer(result.data)).toBe(true); + expect(result.type).toBe("BUFFER"); }); it("should handle stream", async () => { const resolver = new AnyToPromise(); @@ -101,8 +100,8 @@ describe("AnyToPromise", () => { return createReadStream(__dirname + "/__mock__/response.txt"); }); - expect(result.type).to.equal("STREAM"); - expect(isStream(result.data)).to.equal(true); + expect(result.type).toBe("STREAM"); + expect(isStream(result.data)).toBe(true); }); it("should catch error", async () => { @@ -112,7 +111,7 @@ describe("AnyToPromise", () => { return "test"; }); - expect(result).to.deep.equal({state: "RESOLVED", data: "test", type: "DATA"}); + expect(result).toEqual({state: "RESOLVED", data: "test", type: "DATA"}); }); it("should handle async error", async () => { @@ -124,7 +123,7 @@ describe("AnyToPromise", () => { }); }); - expect(error?.message).to.deep.equal("test"); + expect(error?.message).toEqual("test"); }); it("should handle sync error", async () => { @@ -136,7 +135,7 @@ describe("AnyToPromise", () => { }); }); - expect(error?.message).to.deep.equal("test"); + expect(error?.message).toEqual("test"); }); it("should handle next callback with error", async () => { @@ -149,6 +148,6 @@ describe("AnyToPromise", () => { }); }); - expect(error?.message).to.deep.equal("test"); + expect(error?.message).toEqual("test"); }); }); diff --git a/packages/core/src/domain/Hooks.spec.ts b/packages/core/src/domain/Hooks.spec.ts index f0c6e1fe137..60c4ca5154c 100644 --- a/packages/core/src/domain/Hooks.spec.ts +++ b/packages/core/src/domain/Hooks.spec.ts @@ -1,31 +1,28 @@ import {Hooks} from "@tsed/core"; -import {expect} from "chai"; -import Sinon from "sinon"; -const sandbox = Sinon.createSandbox(); describe("Hooks", () => { describe("emit", () => { it("should listen a hook and calls listener", () => { const hooks = new Hooks(); - const fn = sandbox.stub(); + const fn = jest.fn(); hooks.on("event", fn); hooks.emit("event", ["arg1"]); - fn.should.have.been.calledWithExactly("arg1"); + expect(fn).toHaveBeenCalledWith("arg1"); hooks.off("event", fn); }); it("should async listen a hook and calls listener", async () => { const hooks = new Hooks(); - const fn = sandbox.stub(); + const fn = jest.fn(); hooks.on("event", fn); await hooks.asyncEmit("event", ["arg1"]); - fn.should.have.been.calledWithExactly("arg1"); + expect(fn).toHaveBeenCalledWith("arg1"); hooks.off("event", fn); }); @@ -33,26 +30,26 @@ describe("Hooks", () => { describe("alter", () => { it("should listen a hook and calls listener", () => { const hooks = new Hooks(); - const fn = sandbox.stub().returns("valueAltered"); + const fn = jest.fn().mockReturnValue("valueAltered"); hooks.on("event", fn); const value = hooks.alter("event", "value"); - fn.should.have.been.calledWithExactly("value"); - expect(value).to.eq("valueAltered"); + expect(fn).toHaveBeenCalledWith("value"); + expect(value).toBe("valueAltered"); hooks.off("event", fn); }); it("should async listen a hook and calls listener", async () => { const hooks = new Hooks(); - const fn = sandbox.stub().returns("valueAltered"); + const fn = jest.fn().mockReturnValue("valueAltered"); hooks.on("event", fn); await hooks.asyncAlter("event", "value", ["arg1"]); - fn.should.have.been.calledWithExactly("value", "arg1"); + expect(fn).toHaveBeenCalledWith("value", "arg1"); hooks.off("event", fn); }); diff --git a/packages/core/src/domain/Metadata.spec.ts b/packages/core/src/domain/Metadata.spec.ts index f51ab67a3a7..a09ca62c799 100644 --- a/packages/core/src/domain/Metadata.spec.ts +++ b/packages/core/src/domain/Metadata.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {Metadata} from "../../src"; function logger(target: any, method?: any, descriptor?: any) { @@ -34,102 +33,102 @@ class Test2 { describe("Metadata", () => { describe("has", () => { it("should return false (String)", () => { - expect(Metadata.has("testunknow", String)).to.equal(false); + expect(Metadata.has("testunknow", String)).toBe(false); }); it("should return false (bad target)", () => { - expect(Metadata.has("testunknow", undefined)).to.equal(false); + expect(Metadata.has("testunknow", undefined)).toBe(false); }); }); describe("set", () => { it("should set meta on a class", () => { - expect(Metadata.set("metadatakey1", "test1", Test)).to.equal(undefined); - expect(Metadata.has("metadatakey1", Test)).to.be.true; + expect(Metadata.set("metadatakey1", "test1", Test)).toBeUndefined(); + expect(Metadata.has("metadatakey1", Test)).toBe(true); }); it("should set meta on instance", () => { - expect(Metadata.set("metadatakey2", "test2", new Test())).to.equal(undefined); - expect(Metadata.has("metadatakey2", Test)).to.be.true; + expect(Metadata.set("metadatakey2", "test2", new Test())).toBeUndefined(); + expect(Metadata.has("metadatakey2", Test)).toBe(true); }); it("should set meta on a method", () => { - expect(Metadata.set("metadatakey3", "test1", Test, "method")).to.equal(undefined); - expect(Metadata.has("metadatakey3", Test, "method")).to.be.true; + expect(Metadata.set("metadatakey3", "test1", Test, "method")).toBeUndefined(); + expect(Metadata.has("metadatakey3", Test, "method")).toBe(true); }); }); describe("get", () => { it("should get meta on a class", () => { - expect(Metadata.get("metadatakey1", Test)).to.equal("test1"); + expect(Metadata.get("metadatakey1", Test)).toBe("test1"); }); it("should get meta on a method", () => { - expect(Metadata.get("metadatakey3", Test, "method")).to.equal("test1"); + expect(Metadata.get("metadatakey3", Test, "method")).toBe("test1"); }); }); describe("getOwn", () => { it("should get meta on a class", () => { - expect(Metadata.getOwn("metadatakey1", Test)).to.equal("test1"); + expect(Metadata.getOwn("metadatakey1", Test)).toBe("test1"); }); it("should get meta on a method", () => { - expect(Metadata.getOwn("metadatakey3", Test, "method")).to.equal("test1"); + expect(Metadata.getOwn("metadatakey3", Test, "method")).toBe("test1"); }); }); describe("delete", () => { it("should remove meta on a class", () => { - expect(Metadata.delete("metadatakey1", Test)).to.equal(true); + expect(Metadata.delete("metadatakey1", Test)).toBe(true); }); }); describe("getType", () => { it("should return attribut type", () => { - expect(Metadata.getType(Test.prototype, "attribut")).to.equal(String); + expect(Metadata.getType(Test.prototype, "attribut")).toBe(String); }); }); describe("getOwnType", () => { it("should return attribut type", () => { - expect(Metadata.getOwnType(Test.prototype, "attribut")).to.equal(String); + expect(Metadata.getOwnType(Test.prototype, "attribut")).toBe(String); }); }); describe("getParamTypes", () => { it("should return types on constructor", () => { - expect(Metadata.getParamTypes(Test)).to.be.an("array"); - expect(Metadata.getParamTypes(Test)[0]).to.equal(String); + expect(Metadata.getParamTypes(Test)).toBeInstanceOf(Array); + expect(Metadata.getParamTypes(Test)[0]).toBe(String); }); it("should return types on method", () => { - expect(Metadata.getParamTypes(Test.prototype, "method")).to.be.an("array"); - expect(Metadata.getParamTypes(Test.prototype, "method")[0]).to.equal(String); + expect(Metadata.getParamTypes(Test.prototype, "method")).toBeInstanceOf(Array); + expect(Metadata.getParamTypes(Test.prototype, "method")[0]).toBe(String); }); }); describe("getOwnParamTypes", () => { it("should return types on constructor", () => { - expect(Metadata.getOwnParamTypes(Test)).to.be.an("array"); - expect(Metadata.getOwnParamTypes(Test)[0]).to.equal(String); + expect(Metadata.getOwnParamTypes(Test)).toBeInstanceOf(Array); + expect(Metadata.getOwnParamTypes(Test)[0]).toBe(String); }); it("should return types on method", () => { - expect(Metadata.getOwnParamTypes(Test.prototype, "method")).to.be.an("array"); - expect(Metadata.getOwnParamTypes(Test.prototype, "method")[0]).to.equal(String); + expect(Metadata.getOwnParamTypes(Test.prototype, "method")).toBeInstanceOf(Array); + expect(Metadata.getOwnParamTypes(Test.prototype, "method")[0]).toBe(String); }); }); describe("getReturnType", () => { it("should return types on method", () => { - expect(Metadata.getReturnType(Test.prototype, "method")).to.equal(Boolean); + expect(Metadata.getReturnType(Test.prototype, "method")).toBe(Boolean); }); }); describe("getOwnReturnType", () => { it("should return types on method", () => { - expect(Metadata.getOwnReturnType(Test.prototype, "method")).to.equal(Boolean); + expect(Metadata.getOwnReturnType(Test.prototype, "method")).toBe(Boolean); }); }); @@ -141,15 +140,15 @@ describe("Metadata", () => { const result = Metadata.getTargetsFromPropertyKey("controller"); - expect(result).to.be.an("array"); + expect(result).toBeInstanceOf(Array); // expect(result.length).to.equal(2); - expect(result.indexOf(Test) > -1).to.be.true; - expect(result.indexOf(Test2) > -1).to.be.true; + expect(result.indexOf(Test) > -1).toBe(true); + expect(result.indexOf(Test2) > -1).toBe(true); const result2 = Metadata.getTargetsFromPropertyKey("controller2"); - expect(result2).to.be.an("array"); - expect(result2.length).to.equal(0); + expect(result2).toBeInstanceOf(Array); + expect(result2.length).toBe(0); }); }); }); diff --git a/packages/core/src/domain/Store.spec.ts b/packages/core/src/domain/Store.spec.ts index 1ce493b1481..1a00dffa9b2 100644 --- a/packages/core/src/domain/Store.spec.ts +++ b/packages/core/src/domain/Store.spec.ts @@ -1,6 +1,4 @@ -import {expect} from "chai"; -import Sinon from "sinon"; -import {CLASS_STORE, descriptorOf, Metadata, METHOD_STORE, PARAM_STORE, PROPERTY_STORE, prototypeOf, Store} from "../../src"; +import {CLASS_STORE, Metadata, METHOD_STORE, PARAM_STORE, PROPERTY_STORE, Store} from "../../src"; class FakeMetadata { attr1: any; @@ -19,174 +17,129 @@ describe("Store", () => { describe("constructor", () => { describe("when metadata should be store on class", () => { let spyGet: any, store: any, store2: any, store3: any; - before(() => { - spyGet = Sinon.spy(Metadata, "getOwn"); + beforeEach(() => { + spyGet = jest.spyOn(Metadata, "getOwn"); store = Store.from(FakeMetadata); store2 = Store.from(FakeMetadata); store3 = Store.from(class {}); store.set("keyTest", {test: "2"}); }); - after(() => { - spyGet.restore(); - }); it("should have been called the Metadata.get()", () => { - expect(spyGet).to.have.been.calledWithExactly(CLASS_STORE, FakeMetadata); + expect(spyGet).toHaveBeenCalledWith(CLASS_STORE, FakeMetadata); }); it("should share the same StoreMap when the signature is equals", () => { - expect(store.get("keyTest")).to.eq(store2.get("keyTest")); + expect(store.get("keyTest")).toBe(store2.get("keyTest")); }); it("should not share the same StoreMap when the signature is not equals", () => { - expect(store.get("keyTest")).not.to.eq(store3.get("keyTest")); + expect(store.get("keyTest")).not.toBe(store3.get("keyTest")); }); }); describe("when metadata should be store on method", () => { - let spyGet: any, store: any; - before(() => { - spyGet = Sinon.spy(Metadata, "getOwn"); - store = Store.from(FakeMetadata, "get", { + it("should have been called the Metadata.get()", () => { + const spyGet = jest.spyOn(Metadata, "getOwn"); + Store.from(FakeMetadata, "get", { value: () => {} }); - }); - after(() => { - spyGet.restore(); - }); - it("should have been called the Metadata.get()", () => { - expect(spyGet).to.have.been.calledWithExactly(METHOD_STORE, FakeMetadata, "get"); + expect(spyGet).toHaveBeenCalledWith(METHOD_STORE, FakeMetadata, "get"); }); }); describe("when metadata should be store on property (1)", () => { - let spyGet: any, store: any; - before(() => { - spyGet = Sinon.spy(Metadata, "getOwn"); - store = Store.from(FakeMetadata, "get"); - }); - after(() => { - spyGet.restore(); - }); - it("should have been called the Metadata.get()", () => { - expect(spyGet).to.have.been.calledWithExactly(PROPERTY_STORE, FakeMetadata, "get"); + const spyGet = jest.spyOn(Metadata, "getOwn"); + const store = Store.from(FakeMetadata, "get"); + expect(spyGet).toHaveBeenCalledWith(PROPERTY_STORE, FakeMetadata, "get"); }); }); describe("when metadata should be store on property (2)", () => { - let spyGet: any, store: any; - before(() => { - spyGet = Sinon.spy(Metadata, "getOwn"); - store = Store.from(FakeMetadata, "get", { + it("should have been called the Metadata.get()", () => { + const spyGet = jest.spyOn(Metadata, "getOwn"); + Store.from(FakeMetadata, "get", { set: () => {} }); - }); - after(() => { - spyGet.restore(); - }); - it("should have been called the Metadata.get()", () => { - expect(spyGet).to.have.been.calledWithExactly(PROPERTY_STORE, FakeMetadata, "get"); + expect(spyGet).toHaveBeenCalledWith(PROPERTY_STORE, FakeMetadata, "get"); }); }); describe("when metadata should be store on property (3)", () => { - let spyGet: any, store: any; - before(() => { - spyGet = Sinon.spy(Metadata, "getOwn"); - store = Store.from(FakeMetadata, "get", { + it("should have been called the Metadata.get()", () => { + const spyGet = jest.spyOn(Metadata, "getOwn"); + Store.from(FakeMetadata, "get", { get: () => {} }); - }); - after(() => { - spyGet.restore(); - }); - it("should have been called the Metadata.get()", () => { - expect(spyGet).to.have.been.calledWithExactly(PROPERTY_STORE, FakeMetadata, "get"); + expect(spyGet).toHaveBeenCalledWith(PROPERTY_STORE, FakeMetadata, "get"); }); }); describe("when metadata should be store on parameters", () => { - let spyGet: any, store: any; - before(() => { - spyGet = Sinon.spy(Metadata, "getOwn"); - store = Store.from(FakeMetadata, "get", 0); - }); - after(() => { - spyGet.restore(); - }); - it("should have been called the Metadata.get()", () => { - expect(spyGet).to.have.been.calledWithExactly(PARAM_STORE, FakeMetadata, "get"); + const spyGet = jest.spyOn(Metadata, "getOwn"); + Store.from(FakeMetadata, "get", 0); + + expect(spyGet).toHaveBeenCalledWith(PARAM_STORE, FakeMetadata, "get"); }); }); }); describe("set()", () => { - let store: any; - before(() => { - store = Store.from(FakeMetadata); - store.set("key", {}); - }); it("should add a metadata", () => { - expect(store.get("key")).to.deep.equal({}); + const store = Store.from(FakeMetadata); + store.set("key", {}); + + expect(store.get("key")).toEqual({}); }); }); describe("has()", () => { - let store: any; - before(() => { - store = Store.from(FakeMetadata); - }); it("should return true if class is known", () => { - expect(store.has("key")).to.be.true; + const store = Store.from(FakeMetadata); + expect(store.has("key")).toBe(true); }); it("should return false if class is unknown", () => { - expect(store.has("key2")).to.be.false; + const store = Store.from(FakeMetadata); + expect(store.has("key2")).toBe(false); }); }); describe("delete()", () => { - let store: any; - before(() => { - store = Store.from(FakeMetadata); - }); it("should remove key", () => { + const store = Store.from(FakeMetadata); store.set("key", {test: true}); - expect(store.get("key")).to.deep.equal({test: true}); + + expect(store.get("key")).toEqual({test: true}); + store.delete("key"); - expect(store.get("key")).to.equal(undefined); + expect(store.get("key")).toBeUndefined(); }); }); describe("merge()", () => { - let store: any; - before(() => { - store = Store.from(FakeMetadata); + it("should merge metadata", () => { + const store = Store.from(FakeMetadata); store.merge("key3", {attr1: 1}); store.merge("key3", {attr2: 2}); - }); - it("should merge metadata", () => { - expect(store.get("key3")).to.deep.equal({attr1: 1, attr2: 2}); + expect(store.get("key3")).toEqual({attr1: 1, attr2: 2}); }); }); describe("inheritance", () => { - let r1: any, r2: any; - before(() => { + it("should haven't the same sc", () => { Store.from(FakeMetadata).set("sc", {test: "test"}); Store.from(SuperFake).set("sc", {test: "test2"}); - r1 = Store.from(SuperFake).get("sc"); - r2 = Store.from(FakeMetadata).get("sc"); - }); + const r1 = Store.from(SuperFake).get("sc"); + const r2 = Store.from(FakeMetadata).get("sc"); - it("should haven't the same sc", () => { - expect(r1).to.not.deep.equal(r2); + expect(r1).not.toEqual(r2); }); }); @@ -203,8 +156,8 @@ describe("Store", () => { // WHEN store1.set("test", "value"); - expect(store2.get("test")).to.eq("value"); - expect(store3.get("test")).to.eq(undefined); + expect(store2.get("test")).toBe("value"); + expect(store3.get("test")).toBeUndefined(); }); }); }); diff --git a/packages/core/src/domain/index.ts b/packages/core/src/domain/index.ts deleted file mode 100644 index c420236dcb9..00000000000 --- a/packages/core/src/domain/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from "./DecoratorTypes"; -export * from "./Env"; -export * from "./Hooks"; -export * from "./Metadata"; -export * from "./Store"; -export * from "./Type"; -export * from "./AnyToPromise"; diff --git a/packages/core/src/errors/UnsupportedDecoratorType.spec.ts b/packages/core/src/errors/UnsupportedDecoratorType.spec.ts index 674ec4a4507..889491bd1cd 100644 --- a/packages/core/src/errors/UnsupportedDecoratorType.spec.ts +++ b/packages/core/src/errors/UnsupportedDecoratorType.spec.ts @@ -1,5 +1,4 @@ import {UnsupportedDecoratorType} from "./UnsupportedDecoratorType"; -import {expect} from "chai"; class Test {} @@ -9,15 +8,15 @@ describe("UnsupportedDecoratorType", () => { }; it("should return class", () => { - expect(createError([Test])).to.equal("Decorator cannot be used as class decorator on Test"); + expect(createError([Test])).toBe("Decorator cannot be used as class decorator on Test"); }); it("should return property (static)", () => { - expect(createError([Test, "props"])).to.equal("Decorator cannot be used as property.static decorator on Test.props"); + expect(createError([Test, "props"])).toBe("Decorator cannot be used as property.static decorator on Test.props"); }); it("should return property (instance)", () => { - expect(createError([Test.prototype, "props"])).to.equal("Decorator cannot be used as property decorator on Test.props"); + expect(createError([Test.prototype, "props"])).toBe("Decorator cannot be used as property decorator on Test.props"); }); it("should return method (instance, getter)", () => { @@ -29,7 +28,7 @@ describe("UnsupportedDecoratorType", () => { get: () => {} } ]) - ).to.equal("Decorator cannot be used as property decorator on Test.props"); + ).toBe("Decorator cannot be used as property decorator on Test.props"); }); it("should return method (instance, setter)", () => { @@ -41,7 +40,7 @@ describe("UnsupportedDecoratorType", () => { set: () => {} } ]) - ).to.equal("Decorator cannot be used as property decorator on Test.props"); + ).toBe("Decorator cannot be used as property decorator on Test.props"); }); it("should return method (static)", () => { @@ -53,7 +52,7 @@ describe("UnsupportedDecoratorType", () => { value: () => {} } ]) - ).to.equal("Decorator cannot be used as method.static decorator on Test.props"); + ).toBe("Decorator cannot be used as method.static decorator on Test.props"); }); it("should return method (instance)", () => { @@ -65,18 +64,18 @@ describe("UnsupportedDecoratorType", () => { value: () => {} } ]) - ).to.equal("Decorator cannot be used as method decorator on Test.props"); + ).toBe("Decorator cannot be used as method decorator on Test.props"); }); it("should return params (static)", () => { - expect(createError([Test, "props", 0])).to.equal("Decorator cannot be used as parameter.static decorator on Test.props"); + expect(createError([Test, "props", 0])).toBe("Decorator cannot be used as parameter.static decorator on Test.props"); }); it("should return params (instance)", () => { - expect(createError([Test.prototype, "props", 0])).to.equal("Decorator cannot be used as parameter decorator on Test.props.[0]"); + expect(createError([Test.prototype, "props", 0])).toBe("Decorator cannot be used as parameter decorator on Test.props.[0]"); }); it("should return params (constructor)", () => { - expect(createError([Test.prototype, undefined, 0])).to.equal("Decorator cannot be used as parameter.constructor decorator on Test"); + expect(createError([Test.prototype, undefined, 0])).toBe("Decorator cannot be used as parameter.constructor decorator on Test"); }); }); diff --git a/packages/core/src/errors/UnsupportedDecoratorType.ts b/packages/core/src/errors/UnsupportedDecoratorType.ts index 8653b98a6f9..17694a75384 100644 --- a/packages/core/src/errors/UnsupportedDecoratorType.ts +++ b/packages/core/src/errors/UnsupportedDecoratorType.ts @@ -1,4 +1,6 @@ -import {classOf, decoratorTypeOf, nameOf} from "../utils"; +import {decoratorTypeOf} from "../utils/decorators/decoratorTypeOf"; +import {classOf} from "../utils/objects/classOf"; +import {nameOf} from "../utils/objects/nameOf"; export class UnsupportedDecoratorType extends Error { name: "UNSUPPORTED_DECORATOR_TYPE"; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index f747cd8cd99..8d57bc945f2 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,7 +1,82 @@ -import "reflect-metadata"; +/** + * @file Automatically generated by barrelsby. + */ -export type {DecoratorParameters, DecoratorMethodParameters, StaticMethodDecorator, MetadataTypes, ValueOf, HashOf} from "./interfaces"; -export * from "./utils"; -export * from "./domain"; +export * from "./decorators/configurable"; +export * from "./decorators/deprecated"; +export * from "./decorators/enumerable"; +export * from "./decorators/notConfigurable"; +export * from "./decorators/notEnumerable"; +export * from "./decorators/readOnly"; +export * from "./decorators/storeFn"; +export * from "./decorators/storeMerge"; +export * from "./decorators/storeSet"; +export * from "./decorators/writable"; +export * from "./domain/AnyToPromise"; +export * from "./domain/DecoratorTypes"; +export * from "./domain/Env"; +export * from "./domain/Hooks"; +export * from "./domain/Metadata"; +export * from "./domain/Store"; +export * from "./domain/Type"; export * from "./errors/UnsupportedDecoratorType"; -export * from "./decorators"; +export * from "./interfaces/AnyDecorator"; +export * from "./interfaces/DecoratorParameters"; +export * from "./interfaces/HashOf"; +export * from "./interfaces/MetadataTypes"; +export * from "./interfaces/ValueOf"; +export * from "./utils/catchError"; +export * from "./utils/proxyDelegation"; +export * from "./utils/uniq"; +export * from "./utils/decorators/decorateMethodsOf"; +export * from "./utils/decorators/decoratorArgs"; +export * from "./utils/decorators/decoratorTypeOf"; +export * from "./utils/decorators/inheritedDescriptorOf"; +export * from "./utils/decorators/useDecorators"; +export * from "./utils/decorators/useMethodDecorators"; +export * from "./utils/http/getHostInfoFromPort"; +export * from "./utils/imports/importPackage"; +export * from "./utils/objects/ancestorOf"; +export * from "./utils/objects/ancestorsOf"; +export * from "./utils/objects/classOf"; +export * from "./utils/objects/cleanObject"; +export * from "./utils/objects/constructorOf"; +export * from "./utils/objects/createInstance"; +export * from "./utils/objects/deepClone"; +export * from "./utils/objects/deepExtends"; +export * from "./utils/objects/deepMerge"; +export * from "./utils/objects/descriptorOf"; +export * from "./utils/objects/getClassOrSymbol"; +export * from "./utils/objects/getConstructorArgNames"; +export * from "./utils/objects/getEnumerableKeys"; +export * from "./utils/objects/getValue"; +export * from "./utils/objects/isArray"; +export * from "./utils/objects/isArrowFn"; +export * from "./utils/objects/isBoolean"; +export * from "./utils/objects/isClass"; +export * from "./utils/objects/isCollection"; +export * from "./utils/objects/isDate"; +export * from "./utils/objects/isEmpty"; +export * from "./utils/objects/isEnumerable"; +export * from "./utils/objects/isFunction"; +export * from "./utils/objects/isInheritedFrom"; +export * from "./utils/objects/isNil"; +export * from "./utils/objects/isNumber"; +export * from "./utils/objects/isObject"; +export * from "./utils/objects/isObservable"; +export * from "./utils/objects/isPlainObject"; +export * from "./utils/objects/isPrimitive"; +export * from "./utils/objects/isPromise"; +export * from "./utils/objects/isProtectedKey"; +export * from "./utils/objects/isSerializable"; +export * from "./utils/objects/isStream"; +export * from "./utils/objects/isString"; +export * from "./utils/objects/isSymbol"; +export * from "./utils/objects/methodsOf"; +export * from "./utils/objects/nameOf"; +export * from "./utils/objects/objectKeys"; +export * from "./utils/objects/primitiveOf"; +export * from "./utils/objects/prototypeOf"; +export * from "./utils/objects/setValue"; +export * from "./utils/objects/toMap"; +export * from "./utils/objects/toStringConstructor"; diff --git a/packages/core/src/interfaces/index.ts b/packages/core/src/interfaces/index.ts deleted file mode 100644 index 28ff4d115a8..00000000000 --- a/packages/core/src/interfaces/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type {DecoratorParameters, DecoratorMethodParameters, StaticMethodDecorator} from "./DecoratorParameters"; -export type {MetadataTypes} from "./MetadataTypes"; -export type {ValueOf} from "./ValueOf"; -export type {HashOf} from "./HashOf"; diff --git a/packages/core/src/utils/decorators/decorateMethodsOf.spec.ts b/packages/core/src/utils/decorators/decorateMethodsOf.spec.ts index b20eaaec5d1..3227bcffeb8 100644 --- a/packages/core/src/utils/decorators/decorateMethodsOf.spec.ts +++ b/packages/core/src/utils/decorators/decorateMethodsOf.spec.ts @@ -1,5 +1,4 @@ import {descriptorOf, Store, StoreMerge, StoreSet} from "@tsed/core"; -import {expect} from "chai"; import {decorateMethodsOf} from "./decorateMethodsOf"; describe("decorateMethodsOf", () => { @@ -26,12 +25,12 @@ describe("decorateMethodsOf", () => { // THEN const result = Store.from(Test, "test", descriptorOf(Test, "test")).get("test"); - expect(result).to.eq("test"); + expect(result).toBe("test"); const result2 = Store.from(Test, "test2", descriptorOf(Test, "test2")).get("test"); - expect(result2).to.eq("test2"); + expect(result2).toBe("test2"); - expect(new Test().test2("1")).to.eq("test1"); + expect(new Test().test2("1")).toBe("test1"); }); it("should decorate all methods and copy store metadata to the new property", () => { function decorate() { @@ -59,7 +58,7 @@ describe("decorateMethodsOf", () => { // THEN const storeObj2 = Store.fromMethod(Test, "test2").toJson(); - expect(storeObj2).to.deep.eq({ + expect(storeObj2).toEqual({ options: { parent: "test2" }, @@ -68,7 +67,7 @@ describe("decorateMethodsOf", () => { const storeObj = Store.fromMethod(Test, "test").toJson(); // store aren't merged - expect(storeObj).to.deep.eq({ + expect(storeObj).toEqual({ options: { children: "test", override: "child" diff --git a/packages/core/src/utils/decorators/decoratorTypeOf.spec.ts b/packages/core/src/utils/decorators/decoratorTypeOf.spec.ts index a7a73429fb6..3a5f2ee90c3 100644 --- a/packages/core/src/utils/decorators/decoratorTypeOf.spec.ts +++ b/packages/core/src/utils/decorators/decoratorTypeOf.spec.ts @@ -1,19 +1,18 @@ -import {expect} from "chai"; import {decoratorTypeOf} from "./decoratorTypeOf"; class Test {} describe("decoratorTypeOf()", () => { it("should return class", () => { - expect(decoratorTypeOf([Test])).to.equal("class"); + expect(decoratorTypeOf([Test])).toBe("class"); }); it("should return property (static)", () => { - expect(decoratorTypeOf([Test, "props"])).to.equal("property.static"); + expect(decoratorTypeOf([Test, "props"])).toBe("property.static"); }); it("should return property (instance)", () => { - expect(decoratorTypeOf([Test.prototype, "props"])).to.equal("property"); + expect(decoratorTypeOf([Test.prototype, "props"])).toBe("property"); }); it("should return property (instance with descriptor from babel)", () => { @@ -28,7 +27,7 @@ describe("decoratorTypeOf()", () => { initializer: null } ]) - ).to.equal("property"); + ).toBe("property"); }); it("should return method (instance, getter)", () => { @@ -40,7 +39,7 @@ describe("decoratorTypeOf()", () => { get: () => {} } ]) - ).to.equal("property"); + ).toBe("property"); }); it("should return method (instance, setter)", () => { @@ -52,7 +51,7 @@ describe("decoratorTypeOf()", () => { set: () => {} } ]) - ).to.equal("property"); + ).toBe("property"); }); it("should return method (static)", () => { @@ -64,7 +63,7 @@ describe("decoratorTypeOf()", () => { value: () => {} } ]) - ).to.equal("method.static"); + ).toBe("method.static"); }); it("should return method (instance)", () => { @@ -76,18 +75,18 @@ describe("decoratorTypeOf()", () => { value: () => {} } ]) - ).to.equal("method"); + ).toBe("method"); }); it("should return params (static)", () => { - expect(decoratorTypeOf([Test, "props", 0])).to.equal("parameter.static"); + expect(decoratorTypeOf([Test, "props", 0])).toBe("parameter.static"); }); it("should return params (instance)", () => { - expect(decoratorTypeOf([Test.prototype, "props", 0])).to.equal("parameter"); + expect(decoratorTypeOf([Test.prototype, "props", 0])).toBe("parameter"); }); it("should return params (constructor)", () => { - expect(decoratorTypeOf([Test.prototype, undefined, 0])).to.equal("parameter.constructor"); + expect(decoratorTypeOf([Test.prototype, undefined, 0])).toBe("parameter.constructor"); }); }); diff --git a/packages/core/src/utils/decorators/useDecorators.spec.ts b/packages/core/src/utils/decorators/useDecorators.spec.ts index 2d59fe01f2b..fea6bca6bf5 100644 --- a/packages/core/src/utils/decorators/useDecorators.spec.ts +++ b/packages/core/src/utils/decorators/useDecorators.spec.ts @@ -1,5 +1,4 @@ import {Store, StoreFn, useDecorators} from "@tsed/core"; -import {expect} from "chai"; import {AnyDecorator} from "../../interfaces/AnyDecorator"; describe("useDecorators", () => { @@ -23,7 +22,7 @@ describe("useDecorators", () => { class Test {} it("should apply all decorators", () => { - expect(Store.from(Test).get("decorator1")).to.eq("test1"); - expect(Store.from(Test).get("decorator2")).to.eq("test2"); + expect(Store.from(Test).get("decorator1")).toBe("test1"); + expect(Store.from(Test).get("decorator2")).toBe("test2"); }); }); diff --git a/packages/core/src/utils/decorators/useMethodDecorator.spec.ts b/packages/core/src/utils/decorators/useMethodDecorator.spec.ts index af3bc229abd..8af2eab06b7 100644 --- a/packages/core/src/utils/decorators/useMethodDecorator.spec.ts +++ b/packages/core/src/utils/decorators/useMethodDecorator.spec.ts @@ -1,5 +1,4 @@ import {Store, StoreFn, useDecorators, useMethodDecorator, useMethodDecorators} from "@tsed/core"; -import {expect} from "chai"; describe("useMethodDecorators", () => { it("should apply all decorators", () => { @@ -26,8 +25,8 @@ describe("useMethodDecorators", () => { const method1 = Store.fromMethod(Test, "method").get("decorator1"); const method2 = Store.fromMethod(Test, "method").get("decorator2"); const param = Store.from(Test, "method", 0).get("decorator2"); - expect(method1).to.eq("test1"); - expect(method2).to.eq("test3"); - expect(param).to.eq("test2"); + expect(method1).toBe("test1"); + expect(method2).toBe("test3"); + expect(param).toBe("test2"); }); }); diff --git a/packages/core/src/utils/http/getHostInfoFromPort.spec.ts b/packages/core/src/utils/http/getHostInfoFromPort.spec.ts index b0c8dc30ebf..04a71833a37 100644 --- a/packages/core/src/utils/http/getHostInfoFromPort.spec.ts +++ b/packages/core/src/utils/http/getHostInfoFromPort.spec.ts @@ -1,10 +1,9 @@ -import {expect} from "chai"; import {getHostInfoFromPort} from "./getHostInfoFromPort"; describe("buildAddressAndPort()", () => { it("should return address and port from a concatened address and port", () => { const address = getHostInfoFromPort("http", "0.0.0.0:9000"); - expect(address).to.deep.eq({ + expect(address).toEqual({ address: "0.0.0.0", port: 9000, protocol: "http", @@ -14,13 +13,13 @@ describe("buildAddressAndPort()", () => { it("should return address and port from a port number", () => { const address = getHostInfoFromPort("https", 9000); - expect(address).to.deep.eq({ + expect(address).toEqual({ address: "0.0.0.0", port: 9000, protocol: "https", toString: address.toString }); - expect(address.toString()).to.eq("https://0.0.0.0:9000"); + expect(address.toString()).toBe("https://0.0.0.0:9000"); }); }); diff --git a/packages/core/src/utils/imports/importPackage.spec.ts b/packages/core/src/utils/imports/importPackage.spec.ts index 54429a7e494..a2959da7cd9 100644 --- a/packages/core/src/utils/imports/importPackage.spec.ts +++ b/packages/core/src/utils/imports/importPackage.spec.ts @@ -1,29 +1,28 @@ import {importPackage} from "./importPackage"; -import {expect} from "chai"; import {catchAsyncError} from "@tsed/core"; describe("importPackage", () => { it("should load package util", async () => { const util = await importPackage("util"); - expect(!!util).to.be.true; + expect(!!util).toBe(true); }); it("should load package from loaderFn", async () => { const util = await importPackage("util", () => import("util")); - expect(!!util).to.be.true; + expect(!!util).toBe(true); }); it("should throw error", async () => { const error = await catchAsyncError(() => importPackage("@tsed/nowhere")); - expect(error?.message).to.contains("Cannot find module"); + expect(error?.message).toContain("Cannot find module"); }); it("should ignore missing package", async () => { const error = await importPackage("@tsed/nowhere", undefined, true); - expect(error).to.deep.eq({}); + expect(error).toEqual({}); }); }); diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts deleted file mode 100644 index 15b2c07aa42..00000000000 --- a/packages/core/src/utils/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -export * from "./catchError"; -export * from "./proxyDelegation"; -export * from "./uniq"; -export * from "./imports/importPackage"; - -// methods -export * from "./decorators/decorateMethodsOf"; -export * from "./decorators/decoratorArgs"; -export * from "./decorators/decoratorTypeOf"; -export * from "./objects/descriptorOf"; -export * from "./decorators/inheritedDescriptorOf"; -export * from "./decorators/useDecorators"; -export * from "./decorators/useMethodDecorators"; - -// objects -export * from "./objects"; -export * from "./http/getHostInfoFromPort"; diff --git a/packages/core/src/utils/objects/ObjectUtils.spec.ts b/packages/core/src/utils/objects/ObjectUtils.spec.ts index 4bec24e68e6..e796a75967e 100644 --- a/packages/core/src/utils/objects/ObjectUtils.spec.ts +++ b/packages/core/src/utils/objects/ObjectUtils.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import { ancestorsOf, classOf, @@ -36,235 +35,235 @@ const sym = Symbol("test2"); describe("ObjectUtils", () => { describe("getConstructor()", () => { it("should return the constructor when class is given", () => { - expect(getConstructor(Test)).to.eq(Test); + expect(getConstructor(Test)).toBe(Test); }); it("should return the constructor when instance is given", () => { - expect(getConstructor(new Test())).to.eq(Test); + expect(getConstructor(new Test())).toBe(Test); }); }); describe("getClass()", () => { it("should return the class when class is given", () => { - expect(getClass(Test)).to.eq(Test); + expect(getClass(Test)).toBe(Test); }); it("should return the class when instance is given", () => { - expect(getClass(new Test())).to.eq(Test); + expect(getClass(new Test())).toBe(Test); }); it("should return the class when prototype is given", () => { - expect(getClass(Test.prototype)).to.eq(Test); + expect(getClass(Test.prototype)).toBe(Test); }); }); describe("getClassOrSymbol()", () => { it("should return the class when class is given", () => { - expect(getClassOrSymbol(Test)).to.eq(Test); + expect(getClassOrSymbol(Test)).toBe(Test); }); it("should return the class when class is symbol", () => { - expect(getClassOrSymbol(sym)).to.eq(sym); + expect(getClassOrSymbol(sym)).toBe(sym); }); }); describe("isPrimitiveOrPrimitiveClass()", () => { it("should return true when a primitive is given", () => { - expect(isPrimitiveOrPrimitiveClass("test")).to.eq(true); + expect(isPrimitiveOrPrimitiveClass("test")).toBe(true); }); it("should return true when a PrimitiveClass is given", () => { - expect(isPrimitiveOrPrimitiveClass(String())).to.eq(true); + expect(isPrimitiveOrPrimitiveClass(String())).toBe(true); }); it("should return false when a class is given", () => { - expect(isPrimitiveOrPrimitiveClass(Test)).to.eq(false); + expect(isPrimitiveOrPrimitiveClass(Test)).toBe(false); }); }); describe("isArrayOrArrayClass()", () => { it("should return true when Array is given", () => { - expect(isArrayOrArrayClass(Array)).to.eq(true); + expect(isArrayOrArrayClass(Array)).toBe(true); }); it("should return true when Array is given", () => { - expect(isArrayOrArrayClass([])).to.eq(true); + expect(isArrayOrArrayClass([])).toBe(true); }); it("should return true when [] is given", () => { - expect(isArrayOrArrayClass([])).to.eq(true); + expect(isArrayOrArrayClass([])).toBe(true); }); it("should return false when {} is given", () => { - expect(isArrayOrArrayClass({})).to.eq(false); + expect(isArrayOrArrayClass({})).toBe(false); }); }); describe("isCollection()", () => { it("should return true when Array is given", () => { - expect(isCollection(Array)).to.eq(true); + expect(isCollection(Array)).toBe(true); }); it("should return true when Array is given", () => { - expect(isCollection([])).to.eq(true); + expect(isCollection([])).toBe(true); }); it("should return true when [] is given", () => { - expect(isCollection([])).to.eq(true); + expect(isCollection([])).toBe(true); }); it("should return true when Map is given", () => { - expect(isCollection(Map)).to.eq(true); + expect(isCollection(Map)).toBe(true); }); it("should return true when Set is given", () => { - expect(isCollection(Set)).to.eq(true); + expect(isCollection(Set)).toBe(true); }); it("should return true when WeakMap is given", () => { - expect(isCollection(WeakMap)).to.eq(true); + expect(isCollection(WeakMap)).toBe(true); }); it("should return true when WeakSet is given", () => { - expect(isCollection(WeakSet)).to.eq(true); + expect(isCollection(WeakSet)).toBe(true); }); it("should return false when {} is given", () => { - expect(isCollection({})).to.eq(false); + expect(isCollection({})).toBe(false); }); }); describe("isEmpty()", () => { it("should return true when empty string is given", () => { - expect(isEmpty("")).to.eq(true); + expect(isEmpty("")).toBe(true); }); it("should return true when null is given", () => { - expect(isEmpty(null)).to.eq(true); + expect(isEmpty(null)).toBe(true); }); it("should return true when empty string is given", () => { - expect(isEmpty(undefined)).to.eq(true); + expect(isEmpty(undefined)).toBe(true); }); it("should return false when {} is given", () => { - expect(isEmpty({})).to.eq(false); + expect(isEmpty({})).toBe(false); }); it("should return false when [] is given", () => { - expect(isEmpty([])).to.eq(false); + expect(isEmpty([])).toBe(false); }); it("should return false when false is given", () => { - expect(isEmpty(false)).to.eq(false); + expect(isEmpty(false)).toBe(false); }); }); describe("isClass()", () => { it("should return true", () => { - expect(isClass(class {})).to.eq(true); + expect(isClass(class {})).toBe(true); }); it("should return true", () => { - expect(isClass(function t() {})).to.eq(true); + expect(isClass(function t() {})).toBe(true); }); it("should return false (arrow function)", () => { - expect(isClass(() => {})).to.eq(false); + expect(isClass(() => {})).toBe(false); }); it("should return false (date)", () => { - expect(isClass(new Date())).to.eq(false); + expect(isClass(new Date())).toBe(false); }); it("should return false (number)", () => { - expect(isClass(1)).to.eq(false); + expect(isClass(1)).toBe(false); }); it("should return false (obj)", () => { - expect(isClass(Object)).to.eq(false); + expect(isClass(Object)).toBe(false); }); it("should return false (promise)", () => { - expect(isClass(Promise.resolve())).to.eq(false); + expect(isClass(Promise.resolve())).toBe(false); }); }); describe("isPromise()", () => { it("should return true", () => { - expect(isPromise(Promise)).to.eq(true); + expect(isPromise(Promise)).toBe(true); }); it("should return true", () => { - expect(isPromise(Promise.resolve())).to.eq(true); + expect(isPromise(Promise.resolve())).toBe(true); }); }); describe("nameOf", () => { it("should return name when class is given", () => { - expect(nameOf(Test)).to.eq("Test"); + expect(nameOf(Test)).toBe("Test"); }); it("should return name when symbol is given", () => { - expect(nameOf(sym)).to.eq("test2"); + expect(nameOf(sym)).toBe("test2"); }); it("should return name when string is given", () => { - expect(nameOf("test")).to.eq("test"); + expect(nameOf("test")).toBe("test"); }); it("should return name when string is given", () => { - expect(nameOf(1)).to.eq("1"); + expect(nameOf(1)).toBe("1"); }); it("should return name when string is given", () => { - expect(nameOf(true)).to.eq("true"); + expect(nameOf(true)).toBe("true"); }); it("should return name when null is given", () => { - expect(nameOf(null)).to.eq("null"); + expect(nameOf(null)).toBe("null"); }); it("should return name when undefined is given", () => { - expect(nameOf(undefined)).to.eq("undefined"); + expect(nameOf(undefined)).toBe("undefined"); }); }); describe("nameOfClass", () => { it("should return name when class is given", () => { - expect(nameOfClass(Test)).to.eq("Test"); + expect(nameOfClass(Test)).toBe("Test"); }); it("should return name when instance is given", () => { - expect(nameOfClass(new Test())).to.eq("Test"); + expect(nameOfClass(new Test())).toBe("Test"); }); }); describe("primitiveOf", () => { it("should return string", () => { - expect(primitiveOf(String)).to.eq("string"); + expect(primitiveOf(String)).toBe("string"); }); it("should return number", () => { - expect(primitiveOf(Number)).to.eq("number"); + expect(primitiveOf(Number)).toBe("number"); }); it("should return boolean", () => { - expect(primitiveOf(Boolean)).to.eq("boolean"); + expect(primitiveOf(Boolean)).toBe("boolean"); }); it("should return any", () => { - expect(primitiveOf(Object)).to.eq("any"); + expect(primitiveOf(Object)).toBe("any"); }); }); describe("constructorOf()", () => { it("should return the constructor when class is given", () => { - expect(constructorOf(Test)).to.eq(Test); + expect(constructorOf(Test)).toBe(Test); }); it("should return the constructor when instance is given", () => { - expect(constructorOf(new Test())).to.eq(Test); + expect(constructorOf(new Test())).toBe(Test); }); }); describe("classOf()", () => { it("should return the class when class is given", () => { - expect(classOf(Test)).to.eq(Test); + expect(classOf(Test)).toBe(Test); }); it("should return the class when instance is given", () => { - expect(classOf(new Test())).to.eq(Test); + expect(classOf(new Test())).toBe(Test); }); it("should return the class when prototype is given", () => { - expect(classOf(Test.prototype)).to.eq(Test); + expect(classOf(Test.prototype)).toBe(Test); }); }); describe("ancestorsOf()", () => { @@ -273,15 +272,15 @@ describe("ObjectUtils", () => { class Test extends Base {} - expect(ancestorsOf(Test)).to.deep.eq([Base, Test]); - expect(ancestorsOf(Test).reverse()).to.deep.eq([Test, Base]); + expect(ancestorsOf(Test)).toEqual([Base, Test]); + expect(ancestorsOf(Test).reverse()).toEqual([Test, Base]); }); }); describe("methodsOf", () => { it("should return all methods", () => { const methods = methodsOf(Test); - expect(methods).to.deep.eq([ + expect(methods).toEqual([ {propertyKey: "test1", target: Test}, {propertyKey: "test3", target: Base}, {propertyKey: "test2", target: Test} @@ -294,7 +293,7 @@ describe("ObjectUtils", () => { class Test2 extends Test1 {} - expect(isInheritedFrom(Test2, Test1)).to.eq(true); + expect(isInheritedFrom(Test2, Test1)).toBe(true); }); it("should return false when deep is down", () => { class Test1 {} @@ -303,7 +302,7 @@ describe("ObjectUtils", () => { class Test3 extends Test2 {} - expect(isInheritedFrom(Test3, Test1, 1)).to.eq(false); + expect(isInheritedFrom(Test3, Test1, 1)).toBe(false); }); it("should return true when deep is not down", () => { @@ -313,7 +312,7 @@ describe("ObjectUtils", () => { class Test3 extends Test2 {} - expect(isInheritedFrom(Test3, Test1, 3)).to.eq(true); + expect(isInheritedFrom(Test3, Test1, 3)).toBe(true); }); it("should return false when class isn't inherit from another", () => { @@ -321,11 +320,11 @@ describe("ObjectUtils", () => { class Test3 {} - expect(isInheritedFrom(Test3, Test1)).to.eq(false); + expect(isInheritedFrom(Test3, Test1)).toBe(false); }); it("should return false when undefined is given", () => { - expect(isInheritedFrom(undefined, undefined)).to.eq(false); + expect(isInheritedFrom(undefined, undefined)).toBe(false); }); }); }); diff --git a/packages/core/src/utils/objects/cleanObject.spec.ts b/packages/core/src/utils/objects/cleanObject.spec.ts new file mode 100644 index 00000000000..aba03e405f2 --- /dev/null +++ b/packages/core/src/utils/objects/cleanObject.spec.ts @@ -0,0 +1,22 @@ +import {cleanObject} from "@tsed/core"; + +describe("cleanObject", () => { + it("should clean undefined value from object", () => { + expect( + cleanObject( + { + test: undefined, + test2: false, + test3: null, + test4: "", + ignored: "key" + }, + ["ignored"] + ) + ).toEqual({ + test2: false, + test3: null, + test4: "" + }); + }); +}); diff --git a/packages/core/src/utils/objects/deepClone.spec.ts b/packages/core/src/utils/objects/deepClone.spec.ts index 69d21080271..218a45cfbf8 100644 --- a/packages/core/src/utils/objects/deepClone.spec.ts +++ b/packages/core/src/utils/objects/deepClone.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {deepClone} from "./deepClone"; describe("deepClone", () => { @@ -45,19 +44,19 @@ describe("deepClone", () => { const cloned = deepClone(original); - expect(cloned).to.deep.eq(original); - expect(cloned).not.to.eq(original); + expect(cloned).toEqual(original); + expect(cloned).not.toBe(original); - expect(cloned.j).instanceOf(Test); - expect(cloned.j.test).to.eq("test"); - expect(cloned.j.test2).to.eq("test2"); + expect(cloned.j).toBeInstanceOf(Test); + expect(cloned.j.test).toBe("test"); + expect(cloned.j.test2).toBe("test2"); - expect(cloned.k).instanceOf(Array); - expect(cloned.k.length).to.eq(4); - expect(cloned.k[0]).instanceOf(Test); - expect(cloned.k[3]).eq(Test); + expect(cloned.k).toBeInstanceOf(Array); + expect(cloned.k.length).toBe(4); + expect(cloned.k[0]).toBeInstanceOf(Test); + expect(cloned.k[3]).toBe(Test); - expect(deepClone(new Test("test"))).instanceOf(Test); + expect(deepClone(new Test("test"))).toBeInstanceOf(Test); }); it("should clone object with circular obj", () => { const original = { @@ -76,6 +75,6 @@ describe("deepClone", () => { original.posts[0].user = original.user; original.user.posts.push(original.posts[0]); - expect(deepClone(original)).to.deep.eq(original); + expect(deepClone(original)).toEqual(original); }); }); diff --git a/packages/core/src/utils/objects/deepExtends.spec.ts b/packages/core/src/utils/objects/deepExtends.spec.ts index d87fd7157c2..e1e6d2a8744 100644 --- a/packages/core/src/utils/objects/deepExtends.spec.ts +++ b/packages/core/src/utils/objects/deepExtends.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {deepExtends} from "../../index"; describe("deepExtends", () => { @@ -12,7 +11,7 @@ describe("deepExtends", () => { }, undefined ) - ).to.deep.eq({ + ).toEqual({ security: ["o"] }); }); @@ -29,14 +28,14 @@ describe("deepExtends", () => { withClass: new klass() } ); - expect(result).to.deep.eq({ + expect(result).toEqual({ security: ["o", "o1"], withClass: { test: "test" } }); - expect(result.withClass).to.be.instanceof(klass); + expect(result.withClass).toBeInstanceOf(klass); }); it("should merge data (3)", () => { expect( @@ -48,7 +47,7 @@ describe("deepExtends", () => { security: [{"1": "o"}, {"2": "o1"}] } ) - ).to.deep.eq({ + ).toEqual({ security: [{"1": "o"}, {"1": "o"}, {"2": "o1"}] }); }); @@ -62,21 +61,21 @@ describe("deepExtends", () => { }, obj ) - ).to.deep.eq({ + ).toEqual({ security: [{"1": "o"}, {"1": "o"}, {"2": "o1"}] }); - expect(({} as any).a).to.eq(undefined); + expect(({} as any).a).toBeUndefined(); }); }); describe("when is an array", () => { it("should merge data (1)", () => { - expect(deepExtends(["1", "2", "4"], ["1", "2", "3"])).to.deep.eq(["1", "2", "4", "3"]); + expect(deepExtends(["1", "2", "4"], ["1", "2", "3"])).toEqual(["1", "2", "4", "3"]); }); it("should merge data (2)", () => { - expect(deepExtends([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).to.deep.eq([ + expect(deepExtends([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).toEqual([ {"1": "1"}, {"2": "2"}, {"4": "4"}, @@ -109,7 +108,7 @@ describe("deepExtends", () => { } } ) - ).to.deep.eq({ + ).toEqual({ security: ["o", "o1"] }); }); @@ -151,7 +150,7 @@ describe("deepExtends", () => { } } ) - ).to.deep.eq({ + ).toEqual({ parameters: [ {in: "test", name: "get", description: "test2"}, {in: "test", name: "post", description: "test"}, @@ -163,11 +162,11 @@ describe("deepExtends", () => { describe("when is an array", () => { it("should merge data", () => { - expect(deepExtends(["1", "2", "4"], ["1", "2", "3"])).to.deep.eq(["1", "2", "4", "3"]); + expect(deepExtends(["1", "2", "4"], ["1", "2", "3"])).toEqual(["1", "2", "4", "3"]); }); it("should merge data", () => { - expect(deepExtends([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).to.deep.eq([ + expect(deepExtends([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).toEqual([ {"1": "1"}, {"2": "2"}, {"4": "4"}, diff --git a/packages/core/src/utils/objects/deepMerge.spec.ts b/packages/core/src/utils/objects/deepMerge.spec.ts index eee6be5411c..7973589ae2a 100644 --- a/packages/core/src/utils/objects/deepMerge.spec.ts +++ b/packages/core/src/utils/objects/deepMerge.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {deepMerge} from "./deepMerge"; describe("deepMerge", () => { @@ -12,7 +11,7 @@ describe("deepMerge", () => { }, undefined ) - ).to.deep.eq({ + ).toEqual({ security: ["o"] }); }); @@ -29,14 +28,14 @@ describe("deepMerge", () => { withClass: new klass() } ); - expect(result).to.deep.eq({ + expect(result).toEqual({ security: ["o", "o1"], withClass: { test: "test" } }); - expect(result.withClass).to.be.instanceof(klass); + expect(result.withClass).toBeInstanceOf(klass); }); it("should merge data (3)", () => { expect( @@ -48,7 +47,7 @@ describe("deepMerge", () => { security: [{"1": "o"}, {"2": "o1"}] } ) - ).to.deep.eq({ + ).toEqual({ security: [{"1": "o"}, {"1": "o"}, {"2": "o1"}] }); }); @@ -62,7 +61,7 @@ describe("deepMerge", () => { prop: "" } ) - ).to.deep.eq({ + ).toEqual({ prop: {} }); }); @@ -76,21 +75,21 @@ describe("deepMerge", () => { }, obj ) - ).to.deep.eq({ + ).toEqual({ security: [{"1": "o"}, {"1": "o"}, {"2": "o1"}] }); - expect(({} as any).a).to.eq(undefined); + expect(({} as any).a).toBeUndefined(); }); }); describe("when is an array", () => { it("should merge data (1)", () => { - expect(deepMerge(["1", "2", "4"], ["1", "2", "3"])).to.deep.eq(["1", "2", "4", "3"]); + expect(deepMerge(["1", "2", "4"], ["1", "2", "3"])).toEqual(["1", "2", "4", "3"]); }); it("should merge data (2)", () => { - expect(deepMerge([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).to.deep.eq([ + expect(deepMerge([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).toEqual([ {"1": "1"}, {"2": "2"}, {"4": "4"}, @@ -125,7 +124,7 @@ describe("deepMerge", () => { } } ) - ).to.deep.eq({ + ).toEqual({ security: ["o", "o1"] }); }); @@ -169,7 +168,7 @@ describe("deepMerge", () => { } } ) - ).to.deep.eq({ + ).toEqual({ parameters: [ {in: "test", name: "get", description: "test2"}, {in: "test", name: "post", description: "test"}, @@ -181,11 +180,11 @@ describe("deepMerge", () => { describe("when is an array", () => { it("should merge data", () => { - expect(deepMerge(["1", "2", "4"], ["1", "2", "3"])).to.deep.eq(["1", "2", "4", "3"]); + expect(deepMerge(["1", "2", "4"], ["1", "2", "3"])).toEqual(["1", "2", "4", "3"]); }); it("should merge data", () => { - expect(deepMerge([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).to.deep.eq([ + expect(deepMerge([{"1": "1"}, {"2": "2"}, {"4": "4"}], [{"1": "1"}, {"2": "2"}, {"3": "3"}])).toEqual([ {"1": "1"}, {"2": "2"}, {"4": "4"}, diff --git a/packages/core/src/utils/objects/getConstructorArgNames.spec.ts b/packages/core/src/utils/objects/getConstructorArgNames.spec.ts new file mode 100644 index 00000000000..548b9615f33 --- /dev/null +++ b/packages/core/src/utils/objects/getConstructorArgNames.spec.ts @@ -0,0 +1,11 @@ +import {getConstructorArgNames} from "@tsed/core"; + +describe("getConstructorArgNames", () => { + it("should return the constructor args names", () => { + class Test { + constructor(test: string) {} + } + + expect(getConstructorArgNames(Test)).toEqual(["test"]); + }); +}); diff --git a/packages/core/src/utils/objects/getEnumerableKeys.spec.ts b/packages/core/src/utils/objects/getEnumerableKeys.spec.ts index d6b7d5230e4..851e9de4548 100644 --- a/packages/core/src/utils/objects/getEnumerableKeys.spec.ts +++ b/packages/core/src/utils/objects/getEnumerableKeys.spec.ts @@ -1,5 +1,4 @@ import {Enumerable, getEnumerableKeys} from "@tsed/core"; -import {expect} from "chai"; describe("getEnumerableKeys", () => { it("should return enumerable keys", () => { @@ -16,12 +15,12 @@ describe("getEnumerableKeys", () => { } } - expect(getEnumerableKeys(new Test())).to.deep.eq(["test"]); + expect(getEnumerableKeys(new Test())).toEqual(["test"]); }); it("should return enumerable keys (security test)", () => { const obj = JSON.parse('{"__proto__": {"a": "vulnerable"}, "test": "test"}'); - expect(getEnumerableKeys(obj)).to.deep.eq(["test"]); - expect(({} as any).a).to.eq(undefined); + expect(getEnumerableKeys(obj)).toEqual(["test"]); + expect(({} as any).a).toBeUndefined(); }); }); diff --git a/packages/core/src/utils/objects/getValue.spec.ts b/packages/core/src/utils/objects/getValue.spec.ts index b1e2839a281..1c88ef79e87 100644 --- a/packages/core/src/utils/objects/getValue.spec.ts +++ b/packages/core/src/utils/objects/getValue.spec.ts @@ -1,34 +1,33 @@ -import {expect} from "chai"; -import {getValue} from "../index"; +import {getValue} from "./getValue"; describe("getValue()", () => { it("should return given value when expression is undefined", () => { - expect(getValue(undefined, {})).to.deep.eq({}); - expect(getValue({}, undefined)).to.deep.eq({}); + expect(getValue(undefined, {})).toEqual({}); + expect(getValue({}, undefined)).toEqual({}); }); it("should return given value when expression is undefined 2", () => { - expect(getValue(undefined, undefined)).to.deep.eq(undefined); + expect(getValue(undefined, undefined)).toEqual(undefined); }); it("should return given undefined when expression is given but scope doesn't have value", () => { - expect(getValue("user", {})).to.deep.eq(undefined); - expect(getValue({}, "user")).to.deep.eq(undefined); + expect(getValue("user", {})).toEqual(undefined); + expect(getValue({}, "user")).toEqual(undefined); }); it("should return given value when expression is given and scope have value", () => { - expect(getValue("user", {user: "name"})).to.deep.eq("name"); - expect(getValue({user: "name"}, "user")).to.deep.eq("name"); + expect(getValue("user", {user: "name"})).toEqual("name"); + expect(getValue({user: "name"}, "user")).toEqual("name"); }); it("should return given value when expression is given but scope have value (2)", () => { - expect(getValue("user.name", {user: {name: "name"}})).to.deep.eq("name"); - expect(getValue({user: {name: "name"}}, "user.name")).to.deep.eq("name"); + expect(getValue("user.name", {user: {name: "name"}})).toEqual("name"); + expect(getValue({user: {name: "name"}}, "user.name")).toEqual("name"); }); it("should return given value when expression is given but scope have value (3)", () => { - expect(getValue("users.0", {users: [{user: {name: "name"}}]})).to.deep.eq({user: {name: "name"}}); - expect(getValue({users: [{user: {name: "name"}}]}, "users.0")).to.deep.eq({user: {name: "name"}}); + expect(getValue("users.0", {users: [{user: {name: "name"}}]})).toEqual({user: {name: "name"}}); + expect(getValue({users: [{user: {name: "name"}}]}, "users.0")).toEqual({user: {name: "name"}}); }); it("should return given value when expression is given but scope have value (3)", () => { const map = new Map([["user", "name"]]); - expect(getValue("user", map)).to.deep.eq("name"); - expect(getValue(map, "user")).to.deep.eq("name"); + expect(getValue("user", map)).toEqual("name"); + expect(getValue(map, "user")).toEqual("name"); }); it("should return from an object with get method", () => { const map = { @@ -36,12 +35,12 @@ describe("getValue()", () => { return "name"; } }; - expect(getValue("user", map)).to.deep.eq("name"); - expect(getValue(map, "user")).to.deep.eq("name"); + expect(getValue("user", map)).toEqual("name"); + expect(getValue(map, "user")).toEqual("name"); }); it("should return undefined", () => { - expect(getValue("user", undefined)).to.deep.eq(undefined); - expect(getValue(undefined, "user")).to.deep.eq(undefined); + expect(getValue("user", undefined)).toEqual(undefined); + expect(getValue(undefined, "user")).toEqual(undefined); }); it("should return undefined from getter", () => { @@ -58,6 +57,6 @@ describe("getValue()", () => { }, "test" ) - ).to.deep.eq(undefined); + ).toEqual(undefined); }); }); diff --git a/packages/core/src/utils/objects/index.ts b/packages/core/src/utils/objects/index.ts deleted file mode 100644 index 04e8aa4ef61..00000000000 --- a/packages/core/src/utils/objects/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -export * from "./ancestorOf"; -export * from "./ancestorsOf"; -export * from "./classOf"; -export * from "./cleanObject"; -export * from "./constructorOf"; -export * from "./deepClone"; -export * from "./deepExtends"; -export * from "./deepMerge"; -export * from "./getClassOrSymbol"; -export * from "./getConstructorArgNames"; -export * from "./getEnumerableKeys"; -export * from "./ancestorOf"; -export * from "./getValue"; -export * from "./isArray"; -export * from "./isArrowFn"; -export * from "./isBoolean"; -export * from "./isClass"; -export * from "./isCollection"; -export * from "./isDate"; -export * from "./isEmpty"; -export * from "./isEnumerable"; -export * from "./isFunction"; -export * from "./isInheritedFrom"; -export * from "./isNil"; -export * from "./isNumber"; -export * from "./isObject"; -export * from "./isObservable"; -export * from "./isPlainObject"; -export * from "./isPrimitive"; -export * from "./isPromise"; -export * from "./isProtectedKey"; -export * from "./isStream"; -export * from "./isString"; -export * from "./isSymbol"; -export * from "./isSerializable"; -export * from "./methodsOf"; -export * from "./nameOf"; -export * from "./objectKeys"; -export * from "./primitiveOf"; -export * from "./prototypeOf"; -export * from "./setValue"; -export * from "./toMap"; -export * from "./toStringConstructor"; diff --git a/packages/core/src/utils/objects/isClass.spec.ts b/packages/core/src/utils/objects/isClass.spec.ts new file mode 100644 index 00000000000..8c83bdebb3d --- /dev/null +++ b/packages/core/src/utils/objects/isClass.spec.ts @@ -0,0 +1,14 @@ +import {isClass} from "@tsed/core"; + +describe("isClass", () => { + it("should test if a value is a class", () => { + expect(isClass(class Test {})).toEqual(true); + expect(isClass(Date)).toEqual(false); + expect(isClass(undefined)).toEqual(false); + expect(isClass(Symbol("zertyuio"))).toEqual(false); + expect(isClass(Number)).toEqual(false); + expect(isClass(Promise)).toEqual(false); + expect(isClass(Array)).toEqual(false); + expect(isClass(() => {})).toEqual(false); + }); +}); diff --git a/packages/core/src/utils/objects/isEmpty.spec.ts b/packages/core/src/utils/objects/isEmpty.spec.ts index 8687d9e1fb3..1c8b8024b74 100644 --- a/packages/core/src/utils/objects/isEmpty.spec.ts +++ b/packages/core/src/utils/objects/isEmpty.spec.ts @@ -1,11 +1,10 @@ import {isEmpty} from "@tsed/core"; -import {expect} from "chai"; describe("isEmpty", () => { it("should return true", () => { - expect(isEmpty(null)).to.eq(true); - expect(isEmpty(undefined)).to.eq(true); - expect(isEmpty(1)).to.eq(false); - expect(isEmpty("")).to.eq(true); + expect(isEmpty(null)).toBe(true); + expect(isEmpty(undefined)).toBe(true); + expect(isEmpty(1)).toBe(false); + expect(isEmpty("")).toBe(true); }); }); diff --git a/packages/core/src/utils/objects/isNil.spec.ts b/packages/core/src/utils/objects/isNil.spec.ts index 54825aee876..cf66ec03cea 100644 --- a/packages/core/src/utils/objects/isNil.spec.ts +++ b/packages/core/src/utils/objects/isNil.spec.ts @@ -1,11 +1,10 @@ import {isNil} from "@tsed/core"; -import {expect} from "chai"; describe("isNil", () => { it("should return true", () => { - expect(isNil(null)).to.eq(true); - expect(isNil(undefined)).to.eq(true); - expect(isNil(1)).to.eq(false); - expect(isNil("")).to.eq(false); + expect(isNil(null)).toBe(true); + expect(isNil(undefined)).toBe(true); + expect(isNil(1)).toBe(false); + expect(isNil("")).toBe(false); }); }); diff --git a/packages/core/src/utils/objects/isPlainObject.spec.ts b/packages/core/src/utils/objects/isPlainObject.spec.ts new file mode 100644 index 00000000000..688d1fcbc1c --- /dev/null +++ b/packages/core/src/utils/objects/isPlainObject.spec.ts @@ -0,0 +1,9 @@ +import {isPlainObject} from "@tsed/core"; + +describe("isPlainObject", () => { + it("should test if the value is a plain object", () => { + expect(isPlainObject({})).toEqual(true); + expect(isPlainObject(class {})).toEqual(false); + expect(isPlainObject(new (class {})())).toEqual(false); + }); +}); diff --git a/packages/core/src/utils/objects/isPrimitive.spec.ts b/packages/core/src/utils/objects/isPrimitive.spec.ts new file mode 100644 index 00000000000..c09ec198f4f --- /dev/null +++ b/packages/core/src/utils/objects/isPrimitive.spec.ts @@ -0,0 +1,17 @@ +import {isPrimitive, isPrimitiveClass} from "@tsed/core"; + +describe("isPrimitive", () => { + it("should test if an variable content is a primitive", () => { + expect(isPrimitive("1")).toEqual(true); + expect(isPrimitive(1)).toEqual(true); + expect(isPrimitive(true)).toEqual(true); + expect(isPrimitive({})).toEqual(false); + }); + + it("should test if a class is String, Number or Boolean", () => { + expect(isPrimitiveClass(String)).toEqual(true); + expect(isPrimitiveClass(Number)).toEqual(true); + expect(isPrimitiveClass(Boolean)).toEqual(true); + expect(isPrimitiveClass(Date)).toEqual(false); + }); +}); diff --git a/packages/core/src/utils/objects/isProtectedKey.spec.ts b/packages/core/src/utils/objects/isProtectedKey.spec.ts index dae04daa78b..bc101e7a785 100644 --- a/packages/core/src/utils/objects/isProtectedKey.spec.ts +++ b/packages/core/src/utils/objects/isProtectedKey.spec.ts @@ -1,15 +1,14 @@ -import {expect} from "chai"; import {isProtectedKey} from "./isProtectedKey"; describe("isProtectedKey", () => { it("should return true", () => { - expect(isProtectedKey("__proto__")).to.eq(true); - expect(isProtectedKey("prototype")).to.eq(true); - expect(isProtectedKey("constructor")).to.eq(true); + expect(isProtectedKey("__proto__")).toBe(true); + expect(isProtectedKey("prototype")).toBe(true); + expect(isProtectedKey("constructor")).toBe(true); }); it("should return false", () => { - expect(isProtectedKey("test")).to.eq(false); - expect(isProtectedKey("pro")).to.eq(false); - expect(isProtectedKey("const")).to.eq(false); + expect(isProtectedKey("test")).toBe(false); + expect(isProtectedKey("pro")).toBe(false); + expect(isProtectedKey("const")).toBe(false); }); }); diff --git a/packages/core/src/utils/objects/isSerializable.spec.ts b/packages/core/src/utils/objects/isSerializable.spec.ts index f93fc2a26ec..c7f89d1da61 100644 --- a/packages/core/src/utils/objects/isSerializable.spec.ts +++ b/packages/core/src/utils/objects/isSerializable.spec.ts @@ -1,15 +1,14 @@ import {isSerializable} from "@tsed/core"; -import {expect} from "chai"; describe("isSerializable()", () => { it("should return the expected value", () => { - expect(isSerializable(true)).to.equal(false); - expect(isSerializable(null)).to.equal(false); - expect(isSerializable(undefined)).to.equal(false); - expect(isSerializable("")).to.equal(false); - expect(isSerializable("test")).to.equal(false); - expect(isSerializable(0)).to.equal(false); - expect(isSerializable(1)).to.equal(false); - expect(isSerializable({})).to.equal(true); + expect(isSerializable(true)).toBe(false); + expect(isSerializable(null)).toBe(false); + expect(isSerializable(undefined)).toBe(false); + expect(isSerializable("")).toBe(false); + expect(isSerializable("test")).toBe(false); + expect(isSerializable(0)).toBe(false); + expect(isSerializable(1)).toBe(false); + expect(isSerializable({})).toBe(true); }); }); diff --git a/packages/core/src/utils/objects/isSymbol.spec.ts b/packages/core/src/utils/objects/isSymbol.spec.ts index a558b81ec20..68534e0b067 100644 --- a/packages/core/src/utils/objects/isSymbol.spec.ts +++ b/packages/core/src/utils/objects/isSymbol.spec.ts @@ -1,12 +1,11 @@ import {isSymbol, isSymbolOrSymbolClass} from "@tsed/core"; -import {expect} from "chai"; describe("isSymbol()", () => { it("should validate value", () => { - expect(isSymbol(Symbol.for("test"))).to.eq(true); - expect(isSymbol("test")).to.eq(false); - expect(isSymbolOrSymbolClass(Symbol.for("test"))).to.eq(true); - expect(isSymbolOrSymbolClass(Symbol)).to.eq(true); - expect(isSymbolOrSymbolClass("test")).to.eq(false); + expect(isSymbol(Symbol.for("test"))).toBe(true); + expect(isSymbol("test")).toBe(false); + expect(isSymbolOrSymbolClass(Symbol.for("test"))).toBe(true); + expect(isSymbolOrSymbolClass(Symbol)).toBe(true); + expect(isSymbolOrSymbolClass("test")).toBe(false); }); }); diff --git a/packages/core/src/utils/objects/objectKeys.spec.ts b/packages/core/src/utils/objects/objectKeys.spec.ts index 1548488c031..67bf7c33215 100644 --- a/packages/core/src/utils/objects/objectKeys.spec.ts +++ b/packages/core/src/utils/objects/objectKeys.spec.ts @@ -1,11 +1,10 @@ -import {expect} from "chai"; import {objectKeys} from "./objectKeys"; describe("objectKeys", () => { it("should return only authorized keys", () => { const obj = JSON.parse('{"__proto__": {"a": "vulnerable"}, "test": "test"}'); - expect(objectKeys(obj)).to.deep.eq(["test"]); - expect(({} as any).a).to.eq(undefined); + expect(objectKeys(obj)).toEqual(["test"]); + expect(({} as any).a).toBeUndefined(); }); }); diff --git a/packages/core/src/utils/objects/setValue.spec.ts b/packages/core/src/utils/objects/setValue.spec.ts index f694753ff8e..1cc8a407de7 100644 --- a/packages/core/src/utils/objects/setValue.spec.ts +++ b/packages/core/src/utils/objects/setValue.spec.ts @@ -1,53 +1,41 @@ -import {expect} from "chai"; -import {setValue} from "../../index"; +import {setValue} from "./setValue"; describe("setValue()", () => { describe("when map", () => { - let map: Map; - before(() => { - map = new Map(); + it("should set value", () => { + let map: Map = new Map(); setValue(map, "test", "value"); - }); - it("should set value", () => { - expect(map.get("test")).to.eq("value"); + expect(map.get("test")).toBe("value"); }); }); describe("when map with dep", () => { - let map: Map; - before(() => { - map = new Map(); + it("should set value", () => { + let map: Map = new Map(); map.set("test", {t1: "value"}); setValue(map, "test.t1", "value2"); - }); - it("should set value", () => { - expect(map.get("test").t1).to.eq("value2"); + expect(map.get("test").t1).toBe("value2"); }); }); describe("when map with dep (without defined value)", () => { - let map: Map; - before(() => { - map = new Map(); + it("should set value", () => { + let map: Map = new Map(); setValue(map, "test.t1", "value2"); - }); - it("should set value", () => { - expect(map.get("test").t1).to.eq("value2"); + expect(map.get("test").t1).toBe("value2"); }); }); describe("when object with dep (without defined value)", () => { - const map: any = {test: {t1: "value"}}; - before(() => { + it("should set value", () => { + const map: any = {test: {t1: "value"}}; setValue(map, "test.t1", "value2"); - }); - it("should set value", () => { - expect(map.test.t1).to.eq("value2"); + expect(map.test.t1).toBe("value2"); }); }); @@ -55,21 +43,18 @@ describe("setValue()", () => { it("should set value", () => { const obj = {}; setValue(obj, "__proto__", "vulnerable"); - expect(obj).to.deep.eq({}); - expect(({} as any).a).to.eq(undefined); + expect(obj).toEqual({}); + expect(({} as any).a).toBeUndefined(); }); }); describe("when a function is given a value", () => { - let map: any; - before(() => { - map = {}; + it("should set value", () => { + let map: any = {}; setValue(map, "test.deep", () => {}); - }); - it("should set value", () => { - expect(map.test.deep).to.a("function"); + expect(map.test.deep).toBeInstanceOf(Function); }); }); }); diff --git a/packages/core/src/utils/objects/toMap.spec.ts b/packages/core/src/utils/objects/toMap.spec.ts index e8b2c1ee3c5..0c0bfe06912 100644 --- a/packages/core/src/utils/objects/toMap.spec.ts +++ b/packages/core/src/utils/objects/toMap.spec.ts @@ -1,4 +1,3 @@ -import {expect} from "chai"; import {toMap} from "./toMap"; describe("toMap", () => { @@ -9,10 +8,10 @@ describe("toMap", () => { test1: {top: "test1"} }); - expect(result).to.be.instanceof(Map); - expect(result.size).to.equal(2); - expect([...result.keys()]).to.deep.equal(["test", "test1"]); - expect([...result.values()]).to.deep.equal([{top: "test"}, {top: "test1"}]); + expect(result).toBeInstanceOf(Map); + expect(result.size).toBe(2); + expect([...result.keys()]).toEqual(["test", "test1"]); + expect([...result.values()]).toEqual([{top: "test"}, {top: "test1"}]); }); it("should create map by id", () => { const result = toMap( @@ -24,10 +23,10 @@ describe("toMap", () => { "id" ); - expect(result).to.be.instanceof(Map); - expect(result.size).to.equal(2); - expect([...result.keys()]).to.deep.equal(["1", "2"]); - expect([...result.values()]).to.deep.equal([ + expect(result).toBeInstanceOf(Map); + expect(result.size).toBe(2); + expect([...result.keys()]).toEqual(["1", "2"]); + expect([...result.values()]).toEqual([ { id: "1", top: "test" @@ -48,10 +47,10 @@ describe("toMap", () => { (item) => item.id ); - expect(result).to.be.instanceof(Map); - expect(result.size).to.equal(2); - expect([...result.keys()]).to.deep.equal(["1", "2"]); - expect([...result.values()]).to.deep.equal([ + expect(result).toBeInstanceOf(Map); + expect(result.size).toBe(2); + expect([...result.keys()]).toEqual(["1", "2"]); + expect([...result.values()]).toEqual([ { id: "1", top: "test" @@ -80,10 +79,10 @@ describe("toMap", () => { } ]); - expect(result).to.be.instanceof(Map); - expect(result.size).to.equal(2); - expect([...result.keys()]).to.deep.equal(["1", "2"]); - expect([...result.values()]).to.deep.equal([ + expect(result).toBeInstanceOf(Map); + expect(result.size).toBe(2); + expect([...result.keys()]).toEqual(["1", "2"]); + expect([...result.values()]).toEqual([ { id: "1", top: "test" @@ -113,10 +112,10 @@ describe("toMap", () => { "id" ); - expect(result).to.be.instanceof(Map); - expect(result.size).to.equal(2); - expect([...result.keys()]).to.deep.equal(["1", "2"]); - expect([...result.values()]).to.deep.equal([ + expect(result).toBeInstanceOf(Map); + expect(result.size).toBe(2); + expect([...result.keys()]).toEqual(["1", "2"]); + expect([...result.values()]).toEqual([ { id: "1", top: "test" @@ -146,10 +145,10 @@ describe("toMap", () => { (item) => item.id ); - expect(result).to.be.instanceof(Map); - expect(result.size).to.equal(2); - expect([...result.keys()]).to.deep.equal(["1", "2"]); - expect([...result.values()]).to.deep.equal([ + expect(result).toBeInstanceOf(Map); + expect(result.size).toBe(2); + expect([...result.keys()]).toEqual(["1", "2"]); + expect([...result.values()]).toEqual([ { id: "1", top: "test" diff --git a/packages/core/src/utils/proxyDelegation.spec.ts b/packages/core/src/utils/proxyDelegation.spec.ts index d4a17526463..146b4c2234d 100644 --- a/packages/core/src/utils/proxyDelegation.spec.ts +++ b/packages/core/src/utils/proxyDelegation.spec.ts @@ -1,5 +1,4 @@ import {proxyDelegation} from "@tsed/core"; -import {expect} from "chai"; describe("proxyDelegation", () => { it("should create proxy delegation with internal map", () => { @@ -29,21 +28,21 @@ describe("proxyDelegation", () => { const test = new Test(); - expect(test).instanceof(Test); - expect(test.ownP).to.equal("test"); - expect(Object.getOwnPropertyNames(test)).to.deep.equal(["map", "ownP"]); + expect(test).toBeInstanceOf(Test); + expect(test.ownP).toBe("test"); + expect(Object.getOwnPropertyNames(test)).toEqual(["map", "ownP"]); test.newProp = "prop"; - expect(test.newProp).to.equal("prop"); - expect(test.newProp).to.equal("prop"); + expect(test.newProp).toBe("prop"); + expect(test.newProp).toBe("prop"); - expect(Object.getOwnPropertyNames(test)).to.deep.equal(["map", "ownP", "newProp"]); - expect("newProp" in test).to.equal(true); - expect("ownP" in test).to.equal(true); + expect(Object.getOwnPropertyNames(test)).toEqual(["map", "ownP", "newProp"]); + expect("newProp" in test).toBe(true); + expect("ownP" in test).toBe(true); delete test.newProp; - expect(test.newProp).to.equal(undefined); + expect(test.newProp).toBeUndefined(); }); }); diff --git a/packages/core/src/utils/uniq.spec.ts b/packages/core/src/utils/uniq.spec.ts new file mode 100644 index 00000000000..e65d3a7253c --- /dev/null +++ b/packages/core/src/utils/uniq.spec.ts @@ -0,0 +1,8 @@ +import {uniq, uniqBy} from "./uniq"; + +describe("uniq", () => { + it("should return uniq item", () => { + expect(uniq(["test", "test1", "test"])).toEqual(["test", "test1"]); + expect(uniqBy([{id: "test"}, {id: "test1"}, {id: "test"}], "id")).toEqual([{id: "test"}, {id: "test1"}]); + }); +}); diff --git a/packages/core/tsconfig.compile.esm.json b/packages/core/tsconfig.compile.esm.json index 06456ae6499..9457f1de17c 100644 --- a/packages/core/tsconfig.compile.esm.json +++ b/packages/core/tsconfig.compile.esm.json @@ -8,5 +8,5 @@ "declaration": true, "declarationDir": "./lib/types" }, - "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"] + "exclude": ["node_modules", "test", "lib", "coverage", ".nyc_output", "**/*.spec.ts", "jest.config.js"] } diff --git a/packages/core/tsconfig.compile.json b/packages/core/tsconfig.compile.json index c12abdc86b9..90ae3ce92f8 100644 --- a/packages/core/tsconfig.compile.json +++ b/packages/core/tsconfig.compile.json @@ -5,5 +5,5 @@ "outDir": "lib/cjs", "declaration": false }, - "exclude": ["node_modules", "test", "lib", "coverage", ".nyc_output", "**/*.spec.ts"] + "exclude": ["node_modules", "test", "lib", "coverage", ".nyc_output", "**/*.spec.ts", "jest.config.js"] } diff --git a/packages/specs/schema/package.json b/packages/specs/schema/package.json index e4657ad7212..cd13bf91e7a 100644 --- a/packages/specs/schema/package.json +++ b/packages/specs/schema/package.json @@ -49,5 +49,10 @@ }, "peerDependencies": { "@tsed/core": "^6.102.7" + }, + "peerDependenciesMeta": { + "@tsed/code": { + "optional": false + } } -} \ No newline at end of file +} diff --git a/tools/mocha/mocha.config.js b/tools/mocha/mocha.config.js index dbd7c3e83c2..86c7d9beafa 100644 --- a/tools/mocha/mocha.config.js +++ b/tools/mocha/mocha.config.js @@ -14,6 +14,7 @@ module.exports = () => ({ reporter: "dot", spec: ["packages/**/*.spec.ts"], exclude: [ + "packages/core/**/*.spec.ts", "packages/orm/**/*.spec.ts", "packages/graphql/**/*.spec.ts", "packages/utils/**/*.spec.ts", diff --git a/yarn.lock b/yarn.lock index 98bc5d40006..d26ab0e3c22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4440,6 +4440,13 @@ dependencies: "@types/yargs-parser" "*" +"@types/yargs@^17.0.3": + version "17.0.8" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.8.tgz#d23a3476fd3da8a0ea44b5494ca7fa677b9dad4c" + integrity sha512-wDeUwiUmem9FzsyysEwRukaEdDNcwbROvQ9QGRKaLI6t+IltNzbn4/i4asmB10auvZGQCzSQ6t0GSczEThlUXw== + dependencies: + "@types/yargs-parser" "*" + "@typescript-eslint/eslint-plugin@^5.11.0": version "5.11.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.11.0.tgz#3b866371d8d75c70f9b81535e7f7d3aa26527c7a" @@ -5704,6 +5711,15 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +barrelsby@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/barrelsby/-/barrelsby-2.3.2.tgz#1a88c660766a62202bcc38bafe6b963dd41c74f8" + integrity sha512-DLMrQWNe33+TNOEnPRb64f2XsUE2ybOegzxMTDDUzNg/P7s4uOPCLvVnkIS+Xy2lSLBeZWcfKLmPXi4iZb8+1A== + dependencies: + "@types/yargs" "^17.0.3" + signale "^1.4.0" + yargs "^17.3.0" + base64-arraybuffer@0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz#9818c79e059b1355f97e0428a017c838e90ba812" @@ -6290,9 +6306,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001230: - version "1.0.30001239" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001239.tgz#66e8669985bb2cb84ccb10f68c25ce6dd3e4d2b8" - integrity sha512-cyBkXJDMeI4wthy8xJ2FvDU6+0dtcZSJW3voUF8+e9f1bBeuvyZfc3PNbkOETyhbR+dGCPzn9E7MA3iwzusOhQ== + version "1.0.30001312" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz" + integrity sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ== capital-case@^1.0.4: version "1.0.4" @@ -18502,7 +18518,7 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== -signale@^1.2.1: +signale@^1.2.1, signale@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/signale/-/signale-1.4.0.tgz#c4be58302fb0262ac00fc3d886a7c113759042f1" integrity sha512-iuh+gPf28RkltuJC7W5MRi6XAjTDCAPC/prJUpQoG4vIP3MJZ+GTydVnodXA7pwvTKb2cA0m9OFZW/cdWy/I/w== @@ -21247,7 +21263,7 @@ yargs@^16.0.0, yargs@^16.0.3, yargs@^16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" -yargs@^17.0.0: +yargs@^17.0.0, yargs@^17.3.0: version "17.3.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.3.1.tgz#da56b28f32e2fd45aefb402ed9c26f42be4c07b9" integrity sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==