Skip to content

Commit cfda081

Browse files
committed
test: drop unnecessary tests
These are tests for a impure function which basically just wraps an external library. Not really any domain logic going on, so nothing to test really
1 parent 9fd11bd commit cfda081

File tree

1 file changed

+2
-92
lines changed

1 file changed

+2
-92
lines changed

test/integration/io/registry.test.ts

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@ import {
99
} from "../../../src/io/common-errors";
1010
import {
1111
getAllRegistryPackumentsUsing,
12-
getAuthTokenUsing,
1312
getRegistryPackumentUsing,
1413
searchRegistryUsing,
1514
} from "../../../src/io/registry";
1615
import { buildPackument } from "../../common/data-packument";
17-
import { someRegistry, someRegistryUrl } from "../../common/data-registry";
18-
import {
19-
mockRegClientAddUserResult,
20-
mockRegClientGetResult,
21-
} from "./registry-client.mock";
16+
import { someRegistry } from "../../common/data-registry";
17+
import { mockRegClientGetResult } from "./registry-client.mock";
2218

2319
jest.mock("npm-registry-fetch");
2420
jest.mock("libnpmsearch");
@@ -71,92 +67,6 @@ describe("registry io", () => {
7167
});
7268
});
7369

74-
describe("authenticate user with npm registry", () => {
75-
function makeDependencies() {
76-
const registryClient: jest.Mocked<RegClient.Instance> = {
77-
adduser: jest.fn(),
78-
get: jest.fn(),
79-
};
80-
81-
const authenticateUserWithNpmRegistry = getAuthTokenUsing(
82-
registryClient,
83-
noopLogger
84-
);
85-
return { authenticateUserWithNpmRegistry, registryClient } as const;
86-
}
87-
it("should give token for valid user", async () => {
88-
const expected = "some token";
89-
const { authenticateUserWithNpmRegistry, registryClient } =
90-
makeDependencies();
91-
mockRegClientAddUserResult(
92-
registryClient,
93-
null,
94-
{
95-
ok: true,
96-
token: expected,
97-
},
98-
null
99-
);
100-
101-
const actual = await authenticateUserWithNpmRegistry(
102-
someRegistryUrl,
103-
"valid-user",
104-
105-
"valid-password"
106-
);
107-
108-
expect(actual).toEqual(expected);
109-
});
110-
111-
it("should fail for not-ok response", async () => {
112-
const { authenticateUserWithNpmRegistry, registryClient } =
113-
makeDependencies();
114-
mockRegClientAddUserResult(
115-
registryClient,
116-
null,
117-
{
118-
ok: false,
119-
},
120-
{
121-
statusMessage: "bad user",
122-
statusCode: 401,
123-
}
124-
);
125-
126-
await expect(
127-
authenticateUserWithNpmRegistry(
128-
someRegistryUrl,
129-
"bad-user",
130-
131-
"bad-password"
132-
)
133-
).rejects.toBeInstanceOf(RegistryAuthenticationError);
134-
});
135-
136-
it("should fail for error response", async () => {
137-
const { authenticateUserWithNpmRegistry, registryClient } =
138-
makeDependencies();
139-
mockRegClientAddUserResult(
140-
registryClient,
141-
new Error(),
142-
{ ok: false },
143-
{
144-
statusMessage: "bad user",
145-
statusCode: 401,
146-
}
147-
);
148-
149-
await expect(
150-
authenticateUserWithNpmRegistry(
151-
someRegistryUrl,
152-
"bad-user",
153-
154-
"bad-password"
155-
)
156-
).rejects.toBeInstanceOf(Error);
157-
});
158-
});
159-
16070
describe("npm api search", () => {
16171
function makeDependencies() {
16272
const npmApiSearch = searchRegistryUsing(noopLogger);

0 commit comments

Comments
 (0)