Skip to content

Commit 8d7149f

Browse files
committed
refactor(code-style): resolve prettier issues
1 parent 5b0502c commit 8d7149f

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed

test/integration.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ test("Throws error if NPM token is not provided", async (t) => {
131131
t.is(error.message, "No npm token specified.");
132132
});
133133

134-
135134
test("Skip Token validation if the registry configured is not the default one", async (t) => {
136135
const cwd = temporaryDirectory();
137136
const env = { NPM_TOKEN: "wrong_token" };

test/verify-auth.test.js

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import * as td from "testdouble";
33

44
let execa, verifyAuth, getRegistry, setNpmrcAuth;
55
const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org/";
6-
const npmrc = 'npmrc contents';
6+
const npmrc = "npmrc contents";
77
const pkg = {};
8-
const otherEnvVars = {foo: 'bar'}
9-
const env = {DEFAULT_NPM_REGISTRY, ...otherEnvVars};
8+
const otherEnvVars = { foo: "bar" };
9+
const env = { DEFAULT_NPM_REGISTRY, ...otherEnvVars };
1010
const cwd = "./path/to/current/working/directory";
11-
const context = {env, cwd};
11+
const context = { env, cwd };
1212

1313
test.beforeEach(async (t) => {
1414
({ execa } = await td.replaceEsm("execa"));
@@ -22,36 +22,46 @@ test.afterEach.always((t) => {
2222
td.reset();
2323
});
2424

25-
test.serial("that the provided token is verified with `npm whoami` when trusted publishing is not established for the official registry", async (t) => {
26-
td.when(getRegistry(pkg, context)).thenReturn(DEFAULT_NPM_REGISTRY);
27-
td.when(execa("npm", ["whoami", "--userconfig", npmrc, "--registry", DEFAULT_NPM_REGISTRY], {
28-
cwd,
29-
env: otherEnvVars,
30-
preferLocal: true,
31-
})).thenReturn({
32-
stdout: { pipe: () => undefined },
33-
stderr: { pipe: () => undefined }
34-
});
25+
test.serial(
26+
"that the provided token is verified with `npm whoami` when trusted publishing is not established for the official registry",
27+
async (t) => {
28+
td.when(getRegistry(pkg, context)).thenReturn(DEFAULT_NPM_REGISTRY);
29+
td.when(
30+
execa("npm", ["whoami", "--userconfig", npmrc, "--registry", DEFAULT_NPM_REGISTRY], {
31+
cwd,
32+
env: otherEnvVars,
33+
preferLocal: true,
34+
})
35+
).thenReturn({
36+
stdout: { pipe: () => undefined },
37+
stderr: { pipe: () => undefined },
38+
});
3539

36-
await t.notThrowsAsync(verifyAuth(npmrc, pkg, context));
37-
});
40+
await t.notThrowsAsync(verifyAuth(npmrc, pkg, context));
41+
}
42+
);
3843

39-
test.serial("that the auth context for the official registry is considered invalid when no token is provided and trusted publishing is not established", async (t) => {
40-
td.when(getRegistry(pkg, context)).thenReturn(DEFAULT_NPM_REGISTRY);
41-
td.when(execa("npm", ["whoami", "--userconfig", npmrc, "--registry", DEFAULT_NPM_REGISTRY], {
42-
cwd,
43-
env: otherEnvVars,
44-
preferLocal: true,
45-
})).thenThrow(new Error());
46-
47-
const {
48-
errors: [error],
49-
} = await t.throwsAsync(verifyAuth(npmrc, pkg, context));
50-
51-
t.is(error.name, "SemanticReleaseError");
52-
t.is(error.code, "EINVALIDNPMTOKEN");
53-
t.is(error.message, "Invalid npm token.");
54-
});
44+
test.serial(
45+
"that the auth context for the official registry is considered invalid when no token is provided and trusted publishing is not established",
46+
async (t) => {
47+
td.when(getRegistry(pkg, context)).thenReturn(DEFAULT_NPM_REGISTRY);
48+
td.when(
49+
execa("npm", ["whoami", "--userconfig", npmrc, "--registry", DEFAULT_NPM_REGISTRY], {
50+
cwd,
51+
env: otherEnvVars,
52+
preferLocal: true,
53+
})
54+
).thenThrow(new Error());
55+
56+
const {
57+
errors: [error],
58+
} = await t.throwsAsync(verifyAuth(npmrc, pkg, context));
59+
60+
t.is(error.name, "SemanticReleaseError");
61+
t.is(error.code, "EINVALIDNPMTOKEN");
62+
t.is(error.message, "Invalid npm token.");
63+
}
64+
);
5565

5666
// since alternative registries are not consistent in implementing `npm whoami`,
5767
// we do not attempt to verify the provided token when publishing to them

0 commit comments

Comments
 (0)