Skip to content

Commit

Permalink
test: move got tests into got folder (#2542)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Oct 30, 2023
1 parent 3fc5cc3 commit 1d52210
Show file tree
Hide file tree
Showing 37 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_back_filters.js → tests/got/test_back_filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_basic_auth.js → tests/got/test_basic_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_body_match.js → tests/got/test_body_match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()`', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { expect } = require('chai')
const nock = require('..')
const nock = require('../..')
const got = require('./got_client')

describe('`defaultReplyHeaders()`', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_define.js → tests/got/test_define.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()`', () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_delay.js → tests/got/test_delay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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]]]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_events.js → tests/got/test_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fake_timer.js → tests/got/test_fake_timer.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_intercept.js → tests/got/test_intercept.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logging.js → tests/got/test_logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_net_connect.js → tests/got/test_net_connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()`', () => {
Expand Down
8 changes: 4 additions & 4 deletions tests/test_nock_off.js → tests/got/test_nock_off.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()`', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_query.js → tests/got/test_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const nock = require('..')
const nock = require('../..')
const got = require('./got_client')

describe('`query()` complex encoding', () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_recorder.js → tests/got/test_recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_redirects.js → tests/got/test_redirects.js
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { expect } = require('chai')
const nock = require('..')
const nock = require('../..')
const got = require('./got_client')

describe('`removeInterceptor()`', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_repeating.js → tests/got/test_repeating.js
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
2 changes: 1 addition & 1 deletion tests/test_reply_body.js → tests/got/test_reply_body.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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,
}),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Loading

0 comments on commit 1d52210

Please sign in to comment.