From 3ef76dec59778cb73c7cf1cdf3366f76e9545e04 Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Thu, 16 Nov 2023 17:56:28 +0100 Subject: [PATCH] refactor: simplify defined assertions --- test/test-cmd-add.ts | 1 - test/test-cmd-deps.ts | 3 --- test/test-cmd-login.ts | 1 - test/test-cmd-remove.ts | 1 - test/test-cmd-search.ts | 1 - test/test-cmd-view.ts | 1 - test/test-env.ts | 5 ++--- test/test-pgk-info.ts | 5 ++--- test/test-registry-client.ts | 5 ++--- 9 files changed, 6 insertions(+), 17 deletions(-) diff --git a/test/test-cmd-add.ts b/test/test-cmd-add.ts index 1a8b5df9..b24d2a0d 100644 --- a/test/test-cmd-add.ts +++ b/test/test-cmd-add.ts @@ -1,4 +1,3 @@ -import "assert"; import "should"; import { add, AddOptions } from "../src/cmd-add"; import { PkgInfo, PkgManifest } from "../src/types/global"; diff --git a/test/test-cmd-deps.ts b/test/test-cmd-deps.ts index 12fa9048..082e01a9 100644 --- a/test/test-cmd-deps.ts +++ b/test/test-cmd-deps.ts @@ -1,8 +1,5 @@ -import "assert"; import "should"; - import { deps, DepsOptions } from "../src/cmd-deps"; - import { exampleRegistryUrl, registerMissingPackage, diff --git a/test/test-cmd-login.ts b/test/test-cmd-login.ts index 98333918..2c42d653 100644 --- a/test/test-cmd-login.ts +++ b/test/test-cmd-login.ts @@ -1,4 +1,3 @@ -import "assert"; import "nock"; import should from "should"; import { diff --git a/test/test-cmd-remove.ts b/test/test-cmd-remove.ts index 91f90cb6..a288a5bc 100644 --- a/test/test-cmd-remove.ts +++ b/test/test-cmd-remove.ts @@ -1,4 +1,3 @@ -import "assert"; import "should"; import { remove } from "../src/cmd-remove"; import { PkgManifest } from "../src/types/global"; diff --git a/test/test-cmd-search.ts b/test/test-cmd-search.ts index ceb0792d..4e0d97eb 100644 --- a/test/test-cmd-search.ts +++ b/test/test-cmd-search.ts @@ -1,4 +1,3 @@ -import "assert"; import nock from "nock"; import "should"; import { search, SearchOptions } from "../src/cmd-search"; diff --git a/test/test-cmd-view.ts b/test/test-cmd-view.ts index 36400021..377a0930 100644 --- a/test/test-cmd-view.ts +++ b/test/test-cmd-view.ts @@ -1,4 +1,3 @@ -import "assert"; import "should"; import { view, ViewOptions } from "../src/cmd-view"; import { PkgInfo } from "../src/types/global"; diff --git a/test/test-env.ts b/test/test-env.ts index 7df730fa..56622839 100644 --- a/test/test-env.ts +++ b/test/test-env.ts @@ -1,9 +1,9 @@ import "should"; import { env, parseEnv } from "../src/utils/env"; import path from "path"; -import assert from "assert"; import { createWorkDir, getWorkDir, removeWorkDir } from "./mock-work-dir"; import { attachMockConsole, MockConsole } from "./mock-console"; +import should from "should"; describe("env", function () { describe("parseEnv", function () { @@ -157,8 +157,7 @@ describe("env", function () { { checkPath: true } ) ).should.be.ok(); - assert(env.editorVersion !== null); - env.editorVersion.should.be.equal("2019.2.13f1"); + should(env.editorVersion).be.equal("2019.2.13f1"); }); it("region cn", async function () { ( diff --git a/test/test-pgk-info.ts b/test/test-pgk-info.ts index 92e0bd75..b78d3331 100644 --- a/test/test-pgk-info.ts +++ b/test/test-pgk-info.ts @@ -1,14 +1,13 @@ import { tryGetLatestVersion } from "../src/utils/pkg-info"; -import assert from "assert"; import "should"; import { describe } from "mocha"; +import should from "should"; describe("pkg-info", function () { describe("tryGetLatestVersion", function () { it("from dist-tags", async function () { const version = tryGetLatestVersion({ "dist-tags": { latest: "1.0.0" } }); - assert(version !== undefined); - version.should.equal("1.0.0"); + should(version).equal("1.0.0"); }); }); }); diff --git a/test/test-registry-client.ts b/test/test-registry-client.ts index c1536c04..668253d4 100644 --- a/test/test-registry-client.ts +++ b/test/test-registry-client.ts @@ -1,6 +1,5 @@ import "assert"; import "should"; -import assert from "assert"; import { parseEnv } from "../src/utils/env"; import { fetchPackageInfo } from "../src/registry-client"; import { PkgInfo } from "../src/types/global"; @@ -11,6 +10,7 @@ import { startMockRegistry, stopMockRegistry, } from "./mock-registry"; +import should from "should"; describe("registry-client", function () { describe("fetchPackageInfo", function () { @@ -34,8 +34,7 @@ describe("registry-client", function () { }; registerRemotePkg(pkgInfoRemote); const info = await fetchPackageInfo("package-a"); - assert(info !== undefined); - info.should.deepEqual(pkgInfoRemote); + should(info).deepEqual(pkgInfoRemote); }); it("404", async function () { (