From 1d5221003e094bbbc32fd97541233f3f6e123f49 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 30 Oct 2023 21:25:00 +0100 Subject: [PATCH] test: move got tests into got folder (#2542) --- package.json | 2 +- tests/{ => got}/got_client.js | 0 tests/{ => got}/test_allow_unmocked.js | 4 ++-- tests/{ => got}/test_allow_unmocked_https.js | 4 ++-- tests/{ => got}/test_back_filters.js | 4 ++-- tests/{ => got}/test_basic_auth.js | 2 +- tests/{ => got}/test_body_match.js | 2 +- tests/{ => got}/test_content_encoding.js | 2 +- tests/{ => got}/test_default_reply_headers.js | 2 +- tests/{ => got}/test_define.js | 2 +- tests/{ => got}/test_delay.js | 4 ++-- tests/{ => got}/test_dynamic_mock.js | 2 +- tests/{ => got}/test_events.js | 4 ++-- tests/{ => got}/test_fake_timer.js | 2 +- tests/{ => got}/test_header_matching.js | 2 +- tests/{ => got}/test_intercept.js | 2 +- tests/{ => got}/test_intercept_parallel.js | 2 +- tests/{ => got}/test_logging.js | 2 +- tests/{ => got}/test_net_connect.js | 4 ++-- tests/{ => got}/test_nock_lifecycle.js | 4 ++-- tests/{ => got}/test_nock_off.js | 8 ++++---- tests/{ => got}/test_persist_optionally.js | 4 ++-- tests/{ => got}/test_query.js | 2 +- tests/{ => got}/test_query_complex.js | 2 +- tests/{ => got}/test_recorder.js | 4 ++-- tests/{ => got}/test_redirects.js | 2 +- tests/{ => got}/test_remove_interceptor.js | 2 +- tests/{ => got}/test_repeating.js | 2 +- tests/{ => got}/test_reply_body.js | 2 +- tests/{ => got}/test_reply_function_async.js | 2 +- tests/{ => got}/test_reply_function_sync.js | 2 +- tests/{ => got}/test_reply_headers.js | 4 ++-- tests/{ => got}/test_reply_with_file.js | 10 +++++----- tests/{ => got}/test_request_overrider.js | 4 ++-- tests/{ => got}/test_scope.js | 8 ++++---- tests/{ => got}/test_stream.js | 4 ++-- tests/{ => got}/test_url_encoding.js | 2 +- 37 files changed, 58 insertions(+), 58 deletions(-) rename tests/{ => got}/got_client.js (100%) rename tests/{ => got}/test_allow_unmocked.js (99%) rename tests/{ => got}/test_allow_unmocked_https.js (97%) rename tests/{ => got}/test_back_filters.js (97%) rename tests/{ => got}/test_basic_auth.js (97%) rename tests/{ => got}/test_body_match.js (99%) rename tests/{ => got}/test_content_encoding.js (97%) rename tests/{ => got}/test_default_reply_headers.js (99%) rename tests/{ => got}/test_define.js (99%) rename tests/{ => got}/test_delay.js (99%) rename tests/{ => got}/test_dynamic_mock.js (98%) rename tests/{ => got}/test_events.js (96%) rename tests/{ => got}/test_fake_timer.js (93%) rename tests/{ => got}/test_header_matching.js (99%) rename tests/{ => got}/test_intercept.js (99%) rename tests/{ => got}/test_intercept_parallel.js (98%) rename tests/{ => got}/test_logging.js (98%) rename tests/{ => got}/test_net_connect.js (97%) rename tests/{ => got}/test_nock_lifecycle.js (98%) rename tests/{ => got}/test_nock_off.js (87%) rename tests/{ => got}/test_persist_optionally.js (98%) rename tests/{ => got}/test_query.js (99%) rename tests/{ => got}/test_query_complex.js (99%) rename tests/{ => got}/test_recorder.js (99%) rename tests/{ => got}/test_redirects.js (94%) rename tests/{ => got}/test_remove_interceptor.js (99%) rename tests/{ => got}/test_repeating.js (98%) rename tests/{ => got}/test_reply_body.js (99%) rename tests/{ => got}/test_reply_function_async.js (99%) rename tests/{ => got}/test_reply_function_sync.js (99%) rename tests/{ => got}/test_reply_headers.js (99%) rename tests/{ => got}/test_reply_with_file.js (86%) rename tests/{ => got}/test_request_overrider.js (99%) rename tests/{ => got}/test_scope.js (96%) rename tests/{ => got}/test_stream.js (98%) rename tests/{ => got}/test_url_encoding.js (91%) diff --git a/package.json b/package.json index fc57f8634..bb26e597a 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "lint:js": "eslint --cache --cache-location './.cache/eslint' '**/*.js'", "lint:js:fix": "eslint --cache --cache-location './.cache/eslint' --fix '**/*.js'", "lint:ts": "dtslint --expectOnly types", - "test": "nyc --reporter=lcov --reporter=text mocha tests", + "test": "nyc --reporter=lcov --reporter=text mocha --recursive tests", "test:coverage": "open coverage/lcov-report/index.html" }, "license": "MIT", diff --git a/tests/got_client.js b/tests/got/got_client.js similarity index 100% rename from tests/got_client.js rename to tests/got/got_client.js diff --git a/tests/test_allow_unmocked.js b/tests/got/test_allow_unmocked.js similarity index 99% rename from tests/test_allow_unmocked.js rename to tests/got/test_allow_unmocked.js index 5e5ea8667..847041c59 100644 --- a/tests/test_allow_unmocked.js +++ b/tests/got/test_allow_unmocked.js @@ -3,10 +3,10 @@ const { expect } = require('chai') const http = require('http') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const { startHttpServer } = require('./servers') +const { startHttpServer } = require('../servers') describe('allowUnmocked option', () => { it('with allowUnmocked, mocked request still works', async () => { diff --git a/tests/test_allow_unmocked_https.js b/tests/got/test_allow_unmocked_https.js similarity index 97% rename from tests/test_allow_unmocked_https.js rename to tests/got/test_allow_unmocked_https.js index 9fdc91e5f..4c6fd162f 100644 --- a/tests/test_allow_unmocked_https.js +++ b/tests/got/test_allow_unmocked_https.js @@ -1,10 +1,10 @@ 'use strict' const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const servers = require('./servers') +const servers = require('../servers') describe('allowUnmocked option (https)', () => { it('Nock with allowUnmocked and an url match', async () => { diff --git a/tests/test_back_filters.js b/tests/got/test_back_filters.js similarity index 97% rename from tests/test_back_filters.js rename to tests/got/test_back_filters.js index 5697fc298..43db1a6ed 100644 --- a/tests/test_back_filters.js +++ b/tests/got/test_back_filters.js @@ -6,9 +6,9 @@ const path = require('path') const rimraf = require('rimraf') const got = require('./got_client') -const { startHttpServer } = require('./servers') +const { startHttpServer } = require('../servers') -const nock = require('../') +const nock = require('../..') const nockBack = nock.back const originalMode = nockBack.currentMode diff --git a/tests/test_basic_auth.js b/tests/got/test_basic_auth.js similarity index 97% rename from tests/test_basic_auth.js rename to tests/got/test_basic_auth.js index bbccbc2a6..378a31b1b 100644 --- a/tests/test_basic_auth.js +++ b/tests/got/test_basic_auth.js @@ -2,7 +2,7 @@ const { expect } = require('chai') const assertRejects = require('assert-rejects') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('basic auth with username and password', () => { diff --git a/tests/test_body_match.js b/tests/got/test_body_match.js similarity index 99% rename from tests/test_body_match.js rename to tests/got/test_body_match.js index ca092fa64..0e3d80a65 100644 --- a/tests/test_body_match.js +++ b/tests/got/test_body_match.js @@ -3,7 +3,7 @@ const assertRejects = require('assert-rejects') const { expect } = require('chai') const FormData = require('form-data') -const nock = require('../') +const nock = require('../..') const got = require('./got_client') describe('`matchBody()`', () => { diff --git a/tests/test_content_encoding.js b/tests/got/test_content_encoding.js similarity index 97% rename from tests/test_content_encoding.js rename to tests/got/test_content_encoding.js index 4358bbc71..7db62dbfa 100644 --- a/tests/test_content_encoding.js +++ b/tests/got/test_content_encoding.js @@ -2,7 +2,7 @@ const { expect } = require('chai') const zlib = require('zlib') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('Content Encoding', () => { diff --git a/tests/test_default_reply_headers.js b/tests/got/test_default_reply_headers.js similarity index 99% rename from tests/test_default_reply_headers.js rename to tests/got/test_default_reply_headers.js index 1e58fa443..d28ce5dd9 100644 --- a/tests/test_default_reply_headers.js +++ b/tests/got/test_default_reply_headers.js @@ -1,7 +1,7 @@ 'use strict' const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('`defaultReplyHeaders()`', () => { diff --git a/tests/test_define.js b/tests/got/test_define.js similarity index 99% rename from tests/test_define.js rename to tests/got/test_define.js index 779546d50..4e4f024d8 100644 --- a/tests/test_define.js +++ b/tests/got/test_define.js @@ -3,7 +3,7 @@ const http = require('http') const { expect } = require('chai') const assertRejects = require('assert-rejects') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('`define()`', () => { diff --git a/tests/test_delay.js b/tests/got/test_delay.js similarity index 99% rename from tests/test_delay.js rename to tests/got/test_delay.js index 91f3d87fc..b4f982548 100644 --- a/tests/test_delay.js +++ b/tests/got/test_delay.js @@ -7,10 +7,10 @@ const http = require('http') const stream = require('stream') const assertRejects = require('assert-rejects') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const textFilePath = path.resolve(__dirname, './assets/reply_file_1.txt') +const textFilePath = path.resolve(__dirname, '../assets/reply_file_1.txt') const textFileContents = fs.readFileSync(textFilePath, { encoding: 'utf8' }) async function resolvesInAtLeast(promise, durationMillis) { diff --git a/tests/test_dynamic_mock.js b/tests/got/test_dynamic_mock.js similarity index 98% rename from tests/test_dynamic_mock.js rename to tests/got/test_dynamic_mock.js index bf800b2d9..3e3754608 100644 --- a/tests/test_dynamic_mock.js +++ b/tests/got/test_dynamic_mock.js @@ -1,7 +1,7 @@ 'use strict' const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') // "dynamic" refers to `reply` getting a single callback argument that returns or calls the callback with an array of [status, [body, headers]]] diff --git a/tests/test_events.js b/tests/got/test_events.js similarity index 96% rename from tests/test_events.js rename to tests/got/test_events.js index c2f9d99a2..613f6e6e6 100644 --- a/tests/test_events.js +++ b/tests/got/test_events.js @@ -5,7 +5,7 @@ const http = require('http') const path = require('path') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') function ignore() {} @@ -62,7 +62,7 @@ it('emits request and request body', async () => { }) it('emits request and replied events when response body is a stream', async () => { - const textFilePath = path.resolve(__dirname, './assets/reply_file_1.txt') + const textFilePath = path.resolve(__dirname, '../assets/reply_file_1.txt') const scope = nock('http://example.test') .get('/') .replyWithFile(200, textFilePath) diff --git a/tests/test_fake_timer.js b/tests/got/test_fake_timer.js similarity index 93% rename from tests/test_fake_timer.js rename to tests/got/test_fake_timer.js index a9f04f34e..620bb1ecd 100644 --- a/tests/test_fake_timer.js +++ b/tests/got/test_fake_timer.js @@ -1,7 +1,7 @@ 'use strict' const fakeTimers = require('@sinonjs/fake-timers') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') // https://github.com/nock/nock/issues/1334 diff --git a/tests/test_header_matching.js b/tests/got/test_header_matching.js similarity index 99% rename from tests/test_header_matching.js rename to tests/got/test_header_matching.js index 61bf72bdc..9d829cfcb 100644 --- a/tests/test_header_matching.js +++ b/tests/got/test_header_matching.js @@ -4,7 +4,7 @@ const http = require('http') const assertRejects = require('assert-rejects') const { expect } = require('chai') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('Header matching', () => { diff --git a/tests/test_intercept.js b/tests/got/test_intercept.js similarity index 99% rename from tests/test_intercept.js rename to tests/got/test_intercept.js index 9b4c42b0a..8fffac52f 100644 --- a/tests/test_intercept.js +++ b/tests/got/test_intercept.js @@ -6,7 +6,7 @@ const { expect } = require('chai') const sinon = require('sinon') const assertRejects = require('assert-rejects') const url = require('url') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') const acceptableGlobalKeys = new Set([ diff --git a/tests/test_intercept_parallel.js b/tests/got/test_intercept_parallel.js similarity index 98% rename from tests/test_intercept_parallel.js rename to tests/got/test_intercept_parallel.js index a38a0b5a9..82a9b0f15 100644 --- a/tests/test_intercept_parallel.js +++ b/tests/got/test_intercept_parallel.js @@ -2,7 +2,7 @@ const { expect } = require('chai') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') // Tests for a regression where multiple ClientRequests call `.end` during the diff --git a/tests/test_logging.js b/tests/got/test_logging.js similarity index 98% rename from tests/test_logging.js rename to tests/got/test_logging.js index be6eda949..39dfb094f 100644 --- a/tests/test_logging.js +++ b/tests/got/test_logging.js @@ -3,7 +3,7 @@ const debug = require('debug') const sinon = require('sinon') const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('Logging using the `debug` package', () => { diff --git a/tests/test_net_connect.js b/tests/got/test_net_connect.js similarity index 97% rename from tests/test_net_connect.js rename to tests/got/test_net_connect.js index c2d120ea1..794180791 100644 --- a/tests/test_net_connect.js +++ b/tests/got/test_net_connect.js @@ -3,10 +3,10 @@ const { expect } = require('chai') const assertRejects = require('assert-rejects') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const servers = require('./servers') +const servers = require('../servers') describe('`disableNetConnect()`', () => { it('prevents connection to unmocked hosts', async () => { diff --git a/tests/test_nock_lifecycle.js b/tests/got/test_nock_lifecycle.js similarity index 98% rename from tests/test_nock_lifecycle.js rename to tests/got/test_nock_lifecycle.js index b9795bf0c..92a07efe8 100644 --- a/tests/test_nock_lifecycle.js +++ b/tests/got/test_nock_lifecycle.js @@ -2,12 +2,12 @@ const http = require('http') const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const sinon = require('sinon') const assertRejects = require('assert-rejects') const got = require('./got_client') -const servers = require('./servers') +const servers = require('../servers') describe('Nock lifecycle functions', () => { describe('`activate()`', () => { diff --git a/tests/test_nock_off.js b/tests/got/test_nock_off.js similarity index 87% rename from tests/test_nock_off.js rename to tests/got/test_nock_off.js index cc2db21d4..5c3a09b59 100644 --- a/tests/test_nock_off.js +++ b/tests/got/test_nock_off.js @@ -2,10 +2,10 @@ const { expect } = require('chai') const http = require('http') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const httpsServer = require('./servers') +const httpsServer = require('../servers') describe('NOCK_OFF env var', () => { let original @@ -41,8 +41,8 @@ describe('NOCK_OFF env var', () => { nock.restore() const originalClient = http.ClientRequest - delete require.cache[require.resolve('..')] - const newNock = require('..') + delete require.cache[require.resolve('../..')] + const newNock = require('../..') expect(http.ClientRequest).to.equal(originalClient) expect(newNock.isActive()).to.equal(false) diff --git a/tests/test_persist_optionally.js b/tests/got/test_persist_optionally.js similarity index 98% rename from tests/test_persist_optionally.js rename to tests/got/test_persist_optionally.js index 245a08392..77f7fe145 100644 --- a/tests/test_persist_optionally.js +++ b/tests/got/test_persist_optionally.js @@ -7,10 +7,10 @@ const http = require('http') const path = require('path') const assertRejects = require('assert-rejects') const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const textFilePath = path.resolve(__dirname, './assets/reply_file_1.txt') +const textFilePath = path.resolve(__dirname, '../assets/reply_file_1.txt') describe('`optionally()`', () => { it('optional mocks do not appear in `pendingMocks()`', () => { diff --git a/tests/test_query.js b/tests/got/test_query.js similarity index 99% rename from tests/test_query.js rename to tests/got/test_query.js index 01a4d6b7b..196b14783 100644 --- a/tests/test_query.js +++ b/tests/got/test_query.js @@ -3,7 +3,7 @@ const { expect } = require('chai') const sinon = require('sinon') const url = require('url') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') const assertRejects = require('assert-rejects') diff --git a/tests/test_query_complex.js b/tests/got/test_query_complex.js similarity index 99% rename from tests/test_query_complex.js rename to tests/got/test_query_complex.js index 93791bc3e..9e73b2347 100644 --- a/tests/test_query_complex.js +++ b/tests/got/test_query_complex.js @@ -1,6 +1,6 @@ 'use strict' -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('`query()` complex encoding', () => { diff --git a/tests/test_recorder.js b/tests/got/test_recorder.js similarity index 99% rename from tests/test_recorder.js rename to tests/got/test_recorder.js index 57cfda602..6bae25eb4 100644 --- a/tests/test_recorder.js +++ b/tests/got/test_recorder.js @@ -6,10 +6,10 @@ const { URLSearchParams } = require('url') const zlib = require('zlib') const sinon = require('sinon') const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const servers = require('./servers') +const servers = require('../servers') describe('Recorder', () => { let globalCount diff --git a/tests/test_redirects.js b/tests/got/test_redirects.js similarity index 94% rename from tests/test_redirects.js rename to tests/got/test_redirects.js index 8dcf59a72..37bd9f59a 100644 --- a/tests/test_redirects.js +++ b/tests/got/test_redirects.js @@ -1,7 +1,7 @@ 'use strict' const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') it('follows redirects', async () => { diff --git a/tests/test_remove_interceptor.js b/tests/got/test_remove_interceptor.js similarity index 99% rename from tests/test_remove_interceptor.js rename to tests/got/test_remove_interceptor.js index 6ac4b4f79..bdc26280f 100644 --- a/tests/test_remove_interceptor.js +++ b/tests/got/test_remove_interceptor.js @@ -1,7 +1,7 @@ 'use strict' const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('`removeInterceptor()`', () => { diff --git a/tests/test_repeating.js b/tests/got/test_repeating.js similarity index 98% rename from tests/test_repeating.js rename to tests/got/test_repeating.js index 0ecb1cdc9..b7f4ead98 100644 --- a/tests/test_repeating.js +++ b/tests/got/test_repeating.js @@ -1,7 +1,7 @@ 'use strict' const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') const assertRejects = require('assert-rejects') diff --git a/tests/test_reply_body.js b/tests/got/test_reply_body.js similarity index 99% rename from tests/test_reply_body.js rename to tests/got/test_reply_body.js index dba4ff5ef..71f44ff7c 100644 --- a/tests/test_reply_body.js +++ b/tests/got/test_reply_body.js @@ -3,7 +3,7 @@ // Tests for the body argument passed to `.reply()`. const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('`reply()` body', () => { diff --git a/tests/test_reply_function_async.js b/tests/got/test_reply_function_async.js similarity index 99% rename from tests/test_reply_function_async.js rename to tests/got/test_reply_function_async.js index c352d00d4..235f7874c 100644 --- a/tests/test_reply_function_async.js +++ b/tests/got/test_reply_function_async.js @@ -7,7 +7,7 @@ const { expect } = require('chai') const assertRejects = require('assert-rejects') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('asynchronous `reply()` function', () => { diff --git a/tests/test_reply_function_sync.js b/tests/got/test_reply_function_sync.js similarity index 99% rename from tests/test_reply_function_sync.js rename to tests/got/test_reply_function_sync.js index d26f4ddf3..df5b58f8f 100644 --- a/tests/test_reply_function_sync.js +++ b/tests/got/test_reply_function_sync.js @@ -7,7 +7,7 @@ const assertRejects = require('assert-rejects') const { expect } = require('chai') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') describe('synchronous `reply()` function', () => { diff --git a/tests/test_reply_headers.js b/tests/got/test_reply_headers.js similarity index 99% rename from tests/test_reply_headers.js rename to tests/got/test_reply_headers.js index 5646f8d66..fb5010cbf 100644 --- a/tests/test_reply_headers.js +++ b/tests/got/test_reply_headers.js @@ -10,10 +10,10 @@ const fakeTimers = require('@sinonjs/fake-timers') const fs = require('fs') const path = require('path') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const textFilePath = path.resolve(__dirname, './assets/reply_file_1.txt') +const textFilePath = path.resolve(__dirname, '../assets/reply_file_1.txt') describe('`reply()` headers', () => { describe('using parameter value', () => { diff --git a/tests/test_reply_with_file.js b/tests/got/test_reply_with_file.js similarity index 86% rename from tests/test_reply_with_file.js rename to tests/got/test_reply_with_file.js index bef3e4b01..473743e7b 100644 --- a/tests/test_reply_with_file.js +++ b/tests/got/test_reply_with_file.js @@ -7,11 +7,11 @@ const path = require('path') const sinon = require('sinon') const { expect } = require('chai') const proxyquire = require('proxyquire').preserveCache() -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const textFilePath = path.resolve(__dirname, './assets/reply_file_1.txt') -const binaryFilePath = path.resolve(__dirname, './assets/reply_file_2.txt.gz') +const textFilePath = path.resolve(__dirname, '../assets/reply_file_1.txt') +const binaryFilePath = path.resolve(__dirname, '../assets/reply_file_2.txt.gz') describe('`replyWithFile()`', () => { it('reply with file', async () => { @@ -65,8 +65,8 @@ describe('`replyWithFile()`', () => { }) describe('with no fs', () => { - const { Scope } = proxyquire('../lib/scope', { - './interceptor': proxyquire('../lib/interceptor', { + const { Scope } = proxyquire('../../lib/scope', { + './interceptor': proxyquire('../../lib/interceptor', { fs: null, }), }) diff --git a/tests/test_request_overrider.js b/tests/got/test_request_overrider.js similarity index 99% rename from tests/test_request_overrider.js rename to tests/got/test_request_overrider.js index 5913f6cab..2b152dd5c 100644 --- a/tests/test_request_overrider.js +++ b/tests/got/test_request_overrider.js @@ -15,11 +15,11 @@ const https = require('https') const { URL } = require('url') const { expect } = require('chai') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const FormData = require('form-data') const got = require('./got_client') -const servers = require('./servers') +const servers = require('../servers') describe('Request Overrider', () => { it('response is an http.IncomingMessage instance', done => { diff --git a/tests/test_scope.js b/tests/got/test_scope.js similarity index 96% rename from tests/test_scope.js rename to tests/got/test_scope.js index 081ecf4eb..51a3a7e0d 100644 --- a/tests/test_scope.js +++ b/tests/got/test_scope.js @@ -5,13 +5,13 @@ const { expect } = require('chai') const sinon = require('sinon') const proxyquire = require('proxyquire').preserveCache() const url = require('url') -const Interceptor = require('../lib/interceptor') -const nock = require('..') +const Interceptor = require('../../lib/interceptor') +const nock = require('../..') const got = require('./got_client') it('scope exposes interceptors', () => { const scopes = nock.load( - path.join(__dirname, 'fixtures', 'good_request.json'), + path.join(__dirname, '..', 'fixtures', 'good_request.json'), ) expect(scopes).to.be.an.instanceOf(Array) @@ -117,7 +117,7 @@ describe('`Scope#remove()`', () => { }) it('loadDefs throws expected when fs is not available', () => { - const { loadDefs } = proxyquire('../lib/scope', { fs: null }) + const { loadDefs } = proxyquire('../../lib/scope', { fs: null }) expect(() => loadDefs()).to.throw(Error, 'No fs') }) diff --git a/tests/test_stream.js b/tests/got/test_stream.js similarity index 98% rename from tests/test_stream.js rename to tests/got/test_stream.js index 5b3feb0bf..373db55b3 100644 --- a/tests/test_stream.js +++ b/tests/got/test_stream.js @@ -7,10 +7,10 @@ const stream = require('stream') const util = require('util') const { expect } = require('chai') const sinon = require('sinon') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') -const textFilePath = path.resolve(__dirname, './assets/reply_file_1.txt') +const textFilePath = path.resolve(__dirname, '../assets/reply_file_1.txt') it('reply with file and pipe response', done => { const scope = nock('http://example.test') diff --git a/tests/test_url_encoding.js b/tests/got/test_url_encoding.js similarity index 91% rename from tests/test_url_encoding.js rename to tests/got/test_url_encoding.js index 9f85e36eb..7519e56e4 100644 --- a/tests/test_url_encoding.js +++ b/tests/got/test_url_encoding.js @@ -1,7 +1,7 @@ 'use strict' const { expect } = require('chai') -const nock = require('..') +const nock = require('../..') const got = require('./got_client') it('url encoding', async () => {