Skip to content

Commit

Permalink
refactor: simplify defined assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeVanti committed Nov 16, 2023
1 parent 63f94ce commit 3ef76de
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion test/test-cmd-add.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "assert";
import "should";
import { add, AddOptions } from "../src/cmd-add";
import { PkgInfo, PkgManifest } from "../src/types/global";
Expand Down
3 changes: 0 additions & 3 deletions test/test-cmd-deps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import "assert";
import "should";

import { deps, DepsOptions } from "../src/cmd-deps";

import {
exampleRegistryUrl,
registerMissingPackage,
Expand Down
1 change: 0 additions & 1 deletion test/test-cmd-login.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "assert";
import "nock";
import should from "should";
import {
Expand Down
1 change: 0 additions & 1 deletion test/test-cmd-remove.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "assert";
import "should";
import { remove } from "../src/cmd-remove";
import { PkgManifest } from "../src/types/global";
Expand Down
1 change: 0 additions & 1 deletion test/test-cmd-search.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "assert";
import nock from "nock";
import "should";
import { search, SearchOptions } from "../src/cmd-search";
Expand Down
1 change: 0 additions & 1 deletion test/test-cmd-view.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "assert";
import "should";
import { view, ViewOptions } from "../src/cmd-view";
import { PkgInfo } from "../src/types/global";
Expand Down
5 changes: 2 additions & 3 deletions test/test-env.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down Expand Up @@ -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 () {
(
Expand Down
5 changes: 2 additions & 3 deletions test/test-pgk-info.ts
Original file line number Diff line number Diff line change
@@ -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");
});
});
});
5 changes: 2 additions & 3 deletions test/test-registry-client.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -11,6 +10,7 @@ import {
startMockRegistry,
stopMockRegistry,
} from "./mock-registry";
import should from "should";

describe("registry-client", function () {
describe("fetchPackageInfo", function () {
Expand All @@ -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 () {
(
Expand Down

0 comments on commit 3ef76de

Please sign in to comment.