Skip to content

Commit f0b30ef

Browse files
committed
Unnest the authed pkg test, use FlowFixMe for afterEach
1 parent 4469ce8 commit f0b30ef

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

__tests__/commands/install.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ import os from 'os';
1717
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
1818

1919
const path = require('path');
20+
const request = require('request');
2021

2122
const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'install');
2223

24+
beforeEach(request.__resetAuthedRequests);
25+
// $FlowFixMe
26+
afterEach(request.__resetAuthedRequests);
27+
2328
test.concurrent('properly find and save build artifacts', async () => {
2429
await runInstall({}, 'artifacts-finds-and-saves', async (config): Promise<void> => {
2530
const cacheFolder = path.join(config.cacheFolder, 'npm-dummy-0.0.0');
@@ -776,24 +781,16 @@ test.concurrent('install uses OS line endings when lockfile doesn\'t exist', asy
776781
});
777782
});
778783

779-
describe('authed registries', (): void => {
780-
const request = require('request');
781-
782-
beforeEach(request.__resetAuthedRequests);
783-
// flow doesn't like afterEach
784-
// afterEach(request.__resetAuthedRequests);
785-
786-
test.concurrent('install a scoped module from authed private registry', (): Promise<void> => {
787-
return runInstall({noLockfile: true}, 'install-from-authed-private-registry', async (config) => {
788-
const authedRequests = request.__getAuthedRequests();
789-
assert.equal(authedRequests[0].url, 'https://registry.yarnpkg.com/@types%2flodash');
790-
assert.equal(authedRequests[0].headers.authorization, 'Bearer abc123');
791-
assert.equal(authedRequests[1].url, 'https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.37.tgz');
792-
assert.equal(authedRequests[1].headers.authorization, 'Bearer abc123');
793-
assert.equal(
794-
(await fs.readFile(path.join(config.cwd, 'node_modules', '@types', 'lodash', 'index.d.ts'))).split('\n')[0],
795-
'// Type definitions for Lo-Dash 4.14',
796-
);
797-
});
784+
test.concurrent('install a scoped module from authed private registry', (): Promise<void> => {
785+
return runInstall({noLockfile: true}, 'install-from-authed-private-registry', async (config) => {
786+
const authedRequests = request.__getAuthedRequests();
787+
assert.equal(authedRequests[0].url, 'https://registry.yarnpkg.com/@types%2flodash');
788+
assert.equal(authedRequests[0].headers.authorization, 'Bearer abc123');
789+
assert.equal(authedRequests[1].url, 'https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.37.tgz');
790+
assert.equal(authedRequests[1].headers.authorization, 'Bearer abc123');
791+
assert.equal(
792+
(await fs.readFile(path.join(config.cwd, 'node_modules', '@types', 'lodash', 'index.d.ts'))).split('\n')[0],
793+
'// Type definitions for Lo-Dash 4.14',
794+
);
798795
});
799796
});

0 commit comments

Comments
 (0)