Skip to content

Commit

Permalink
refactor(test): Mocha DSL for fake timers and gzip (#1927)
Browse files Browse the repository at this point in the history
  • Loading branch information
mastermatt committed Feb 22, 2020
1 parent 9cbb707 commit 0cfa0ed
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
6 changes: 2 additions & 4 deletions tests/test_fake_timer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
'use strict'

const { expect } = require('chai')
const { test } = require('tap')
const request = require('request')
const fakeTimers = require('@sinonjs/fake-timers')
const nock = require('..')

require('./cleanup_after_each')()
require('./setup')

// https://github.com/nock/nock/issues/1334
test('one function returns successfully when fake timer is enabled', t => {
it('should still return successfully when fake timer is enabled', done => {
const clock = fakeTimers.install()
nock('http://example.test')
.get('/')
Expand All @@ -21,6 +19,6 @@ test('one function returns successfully when fake timer is enabled', t => {

expect(err).to.be.null()
expect(resp.statusCode).to.equal(200)
t.end()
done()
})
})
10 changes: 4 additions & 6 deletions tests/test_gzip_request.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
'use strict'

const { expect } = require('chai')
const { test } = require('tap')
const http = require('http')
const zlib = require('zlib')
const nock = require('..')

require('./cleanup_after_each')()
require('./setup')

test('accepts and decodes gzip encoded application/json', t => {
it('should accept and decode gzip encoded application/json', done => {
const message = {
my: 'contents',
}
Expand All @@ -18,7 +16,7 @@ test('accepts and decodes gzip encoded application/json', t => {
.post('/')
.reply(function(url, actual) {
expect(actual).to.deep.equal(message)
t.end()
done()
return [200]
})

Expand All @@ -38,7 +36,7 @@ test('accepts and decodes gzip encoded application/json', t => {
req.end()
})

test('accepts and decodes deflate encoded application/json', t => {
it('should accept and decode deflate encoded application/json', done => {
const message = {
my: 'contents',
}
Expand All @@ -47,7 +45,7 @@ test('accepts and decodes deflate encoded application/json', t => {
.post('/')
.reply(function(url, actual) {
expect(actual).to.deep.equal(message)
t.end()
done()
return [200]
})

Expand Down
1 change: 0 additions & 1 deletion tests/test_persist_optionally.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const { expect } = require('chai')
const nock = require('..')
const got = require('./got_client')

require('./cleanup_after_each')()
require('./setup')

const textFile = path.join(__dirname, '..', 'assets', 'reply_file_1.txt')
Expand Down
1 change: 0 additions & 1 deletion tests/test_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const nock = require('..')
const got = require('./got_client')
const assertRejects = require('assert-rejects')

require('./cleanup_after_each')()
require('./setup')

describe('query params in path', () => {
Expand Down
1 change: 0 additions & 1 deletion tests/test_recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const { expect } = require('chai')
const nock = require('..')
const got = require('./got_client')

require('./cleanup_after_each')()
require('./setup')

let globalCount
Expand Down

0 comments on commit 0cfa0ed

Please sign in to comment.