From 4ec32601e7fdcfc57348286e2c77cc800c1e2ef4 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Thu, 20 May 2021 16:16:45 +0200 Subject: [PATCH] Drop node v10 support (#1471) --- .ci/test-matrix.yml | 2 +- .github/workflows/nodejs.yml | 4 +- index.js | 11 -- lib/Connection.js | 4 +- package.json | 26 ++-- test/acceptance/events-order.test.js | 80 +++++------ test/acceptance/observability.test.js | 62 ++++----- test/acceptance/proxy.test.js | 24 ++-- test/acceptance/resurrect.test.js | 32 ++--- test/acceptance/sniff.test.js | 48 +++---- test/integration/helpers/bulk.test.js | 14 +- test/integration/helpers/msearch.test.js | 10 +- test/integration/helpers/scroll.test.js | 10 +- test/integration/helpers/search.test.js | 4 +- test/integration/test-runner.js | 6 +- test/unit/api-async.js | 2 +- test/unit/api.test.js | 14 +- test/unit/base-connection-pool.test.js | 60 ++++----- test/unit/child.test.js | 10 +- test/unit/client.test.js | 158 +++++++++++----------- test/unit/cloud-connection-pool.test.js | 4 +- test/unit/connection-pool.test.js | 136 +++++++++---------- test/unit/connection.test.js | 82 ++++++------ test/unit/errors.test.js | 66 ++++----- test/unit/esm/index.mjs | 2 +- test/unit/events.test.js | 2 +- test/unit/helpers/bulk.test.js | 126 +++++++++--------- test/unit/helpers/msearch.test.js | 72 +++++----- test/unit/helpers/scroll.test.js | 56 ++++---- test/unit/helpers/search.test.js | 16 +-- test/unit/selectors.test.js | 2 +- test/unit/serializer.test.js | 16 +-- test/unit/transport.test.js | 162 +++++++++++------------ 33 files changed, 655 insertions(+), 668 deletions(-) diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index a10fea1d3..77b998c99 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -3,9 +3,9 @@ STACK_VERSION: - 7.x-SNAPSHOT NODE_JS_VERSION: + - 16 - 14 - 12 - - 10 TEST_SUITE: - free diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 73f75a386..70ae0aec5 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - node-version: [10.x, 12.x, 14.x, 15.x] + node-version: [12.x, 14.x, 16.x] os: [ubuntu-latest, windows-latest, macOS-latest] steps: @@ -46,7 +46,7 @@ jobs: strategy: matrix: - node-version: [10.x, 12.x, 14.x] + node-version: [12.x, 14.x, 16.x] steps: - uses: actions/checkout@v2 diff --git a/index.js b/index.js index 02851266d..e36e6bee4 100644 --- a/index.js +++ b/index.js @@ -19,8 +19,6 @@ 'use strict' -const nodeMajor = Number(process.versions.node.split('.')[0]) - const { EventEmitter } = require('events') const { URL } = require('url') const debug = require('debug')('elasticsearch') @@ -47,15 +45,6 @@ const kEventEmitter = Symbol('elasticsearchjs-event-emitter') const ESAPI = require('./api') -/* istanbul ignore next */ -if (nodeMajor >= 10 && nodeMajor < 12) { - process.emitWarning('You are using a version of Node.js that will reach EOL in April 2021. ' + - 'The support for this version will be dropped in 7.13. ' + - 'Please refer to https://ela.st/nodejs-support for additional information.', - 'DeprecationWarning' - ) -} - class Client extends ESAPI { constructor (opts = {}) { super({ ConfigurationError }) diff --git a/lib/Connection.js b/lib/Connection.js index cb5c7c7f7..20e08f708 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -25,7 +25,7 @@ const hpagent = require('hpagent') const http = require('http') const https = require('https') const debug = require('debug')('elasticsearch') -const pump = require('pump') +const { pipeline } = require('stream') const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/ const { ConnectionError, @@ -133,7 +133,7 @@ class Connection { // starts the request if (isStream(params.body) === true) { - pump(params.body, request, err => { + pipeline(params.body, request, err => { /* istanbul ignore if */ if (err != null && cleanedListeners === false) { cleanListeners() diff --git a/package.json b/package.json index b35d454d7..33a783836 100644 --- a/package.json +++ b/package.json @@ -48,39 +48,38 @@ }, "devDependencies": { "@sinonjs/fake-timers": "github:sinonjs/fake-timers#0bfffc1", - "@types/node": "^14.14.28", - "convert-hrtime": "^3.0.0", + "@types/node": "^15.3.1", + "convert-hrtime": "^5.0.0", "cross-zip": "^4.0.0", "dedent": "^0.7.0", "deepmerge": "^4.2.2", "dezalgo": "^1.0.3", "fast-deep-equal": "^3.1.3", "into-stream": "^6.0.0", - "js-yaml": "^4.0.0", + "js-yaml": "^4.1.0", "license-checker": "^25.0.1", "minimist": "^1.2.5", "node-fetch": "^2.6.1", - "ora": "^5.3.0", + "ora": "^5.4.0", "pretty-hrtime": "^1.0.3", "proxy": "^1.0.2", "rimraf": "^3.0.2", - "semver": "^7.3.4", - "simple-git": "^2.35.0", - "simple-statistics": "^7.4.1", + "semver": "^7.3.5", + "simple-git": "^2.39.0", + "simple-statistics": "^7.7.0", "split2": "^3.2.2", "standard": "^16.0.3", "stoppable": "^1.1.0", - "tap": "^14.11.0", - "tsd": "^0.14.0", + "tap": "^15.0.9", + "tsd": "^0.15.1", "workq": "^3.0.0", - "xmlbuilder2": "^2.4.0" + "xmlbuilder2": "^2.4.1" }, "dependencies": { "debug": "^4.3.1", "hpagent": "^0.1.1", "ms": "^2.1.3", - "pump": "^3.0.0", - "secure-json-parse": "^2.3.1" + "secure-json-parse": "^2.4.0" }, "license": "Apache-2.0", "repository": { @@ -91,13 +90,12 @@ "url": "https://github.com/elastic/elasticsearch-js/issues" }, "engines": { - "node": ">=10" + "node": ">=12" }, "tsd": { "directory": "test/types" }, "tap": { - "esm": false, "ts": false, "jsx": false, "flow": false, diff --git a/test/acceptance/events-order.test.js b/test/acceptance/events-order.test.js index b4a9ff6b3..0bbd9a49a 100644 --- a/test/acceptance/events-order.test.js +++ b/test/acceptance/events-order.test.js @@ -57,27 +57,27 @@ test('No errors', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.DESERIALIZATION) + t.equal(order.shift(), events.DESERIALIZATION) }) client.on(events.RESPONSE, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) client.info((err, result) => { t.error(err) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) }) @@ -99,12 +99,12 @@ test('Connection error', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (_err, request) => { @@ -113,12 +113,12 @@ test('Connection error', t => { client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof ConnectionError) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) client.info((err, result) => { t.ok(err instanceof ConnectionError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) }) @@ -140,12 +140,12 @@ test('TimeoutError error', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (_err, request) => { @@ -154,12 +154,12 @@ test('TimeoutError error', t => { client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof TimeoutError) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) client.info((err, result) => { t.ok(err instanceof TimeoutError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) }) @@ -180,12 +180,12 @@ test('RequestAbortedError error', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (_err, request) => { @@ -194,12 +194,12 @@ test('RequestAbortedError error', t => { client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof RequestAbortedError) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) const request = client.info((err, result) => { t.ok(err instanceof RequestAbortedError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) request.abort() @@ -232,27 +232,27 @@ test('ResponseError error (no retry)', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.DESERIALIZATION) + t.equal(order.shift(), events.DESERIALIZATION) }) client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof ResponseError) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) client.info((err, result) => { t.ok(err instanceof ResponseError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) }) @@ -285,27 +285,27 @@ test('ResponseError error (with retry)', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.DESERIALIZATION) + t.equal(order.shift(), events.DESERIALIZATION) }) client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof ResponseError) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) client.info((err, result) => { t.ok(err instanceof ResponseError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) }) @@ -325,12 +325,12 @@ test('Serialization Error', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.ok(err instanceof SerializationError) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (_err, request) => { @@ -345,7 +345,7 @@ test('Serialization Error', t => { body.o = body client.index({ index: 'test', body }, (err, result) => { t.ok(err instanceof SerializationError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) }) @@ -384,27 +384,27 @@ test('Deserialization Error', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.DESERIALIZATION) + t.equal(order.shift(), events.DESERIALIZATION) }) client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof DeserializationError) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) client.info((err, result) => { t.ok(err instanceof DeserializationError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) }) }) @@ -435,27 +435,27 @@ test('Socket destroyed while reading the body', t => { client.on(events.SERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.SERIALIZATION) + t.equal(order.shift(), events.SERIALIZATION) }) client.on(events.REQUEST, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.REQUEST) + t.equal(order.shift(), events.REQUEST) }) client.on(events.DESERIALIZATION, (err, request) => { t.error(err) - t.strictEqual(order.shift(), events.DESERIALIZATION) + t.equal(order.shift(), events.DESERIALIZATION) }) client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof ConnectionError) - t.strictEqual(order.shift(), events.RESPONSE) + t.equal(order.shift(), events.RESPONSE) }) client.info((err, result) => { t.ok(err instanceof ConnectionError) - t.strictEqual(order.length, 0) + t.equal(order.length, 0) server.stop() }) }) diff --git a/test/acceptance/observability.test.js b/test/acceptance/observability.test.js index d7141b923..2d74b4f32 100644 --- a/test/acceptance/observability.test.js +++ b/test/acceptance/observability.test.js @@ -17,7 +17,7 @@ test('Request id', t => { t.type(genReqId, 'function') for (let i = 1; i <= 10; i++) { - t.strictEqual(genReqId(), i) + t.equal(genReqId(), i) } t.end() @@ -40,12 +40,12 @@ test('Request id', t => { client.on('request', (err, { meta }) => { t.error(err) - t.strictEqual(meta.request.id, 'custom-id') + t.equal(meta.request.id, 'custom-id') }) client.on('response', (err, { meta }) => { t.error(err) - t.strictEqual(meta.request.id, 'custom-id') + t.equal(meta.request.id, 'custom-id') }) client.info({}, options, t.error) @@ -61,12 +61,12 @@ test('Request id', t => { client.on('request', (err, { meta }) => { t.error(err) - t.strictEqual(meta.request.id, 'custom-id') + t.equal(meta.request.id, 'custom-id') }) client.on('response', (err, { meta }) => { t.error(err) - t.strictEqual(meta.request.id, 'custom-id') + t.equal(meta.request.id, 'custom-id') }) client.info({}, { id: 'custom-id' }, t.error) @@ -84,7 +84,7 @@ test('Request id', t => { client.on('sniff', (err, { meta }) => { t.error(err) - t.strictEqual(meta.request.id, 1) + t.equal(meta.request.id, 1) }) }) @@ -99,15 +99,15 @@ test('Request id', t => { }) client.on('request', (e, { meta }) => { - t.strictEqual(meta.request.id, 'custom') + t.equal(meta.request.id, 'custom') }) client.on('response', (e, { meta }) => { - t.strictEqual(meta.request.id, 'custom') + t.equal(meta.request.id, 'custom') }) client.on('sniff', (e, { meta }) => { - t.strictEqual(meta.request.id, 'custom') + t.equal(meta.request.id, 'custom') }) client.transport.request({ @@ -139,7 +139,7 @@ test('Request id', t => { client.on('resurrect', (err, meta) => { t.error(err) - t.strictEqual(meta.request.id, 'custom') + t.equal(meta.request.id, 'custom') clock.uninstall() }) @@ -160,12 +160,12 @@ test('Request context', t => { client.on('request', (err, { meta }) => { t.error(err) - t.strictEqual(meta.context, null) + t.equal(meta.context, null) }) client.on('response', (err, { meta }) => { t.error(err) - t.strictEqual(meta.context, null) + t.equal(meta.context, null) }) client.info(t.error) @@ -181,12 +181,12 @@ test('Request context', t => { client.on('request', (err, { meta }) => { t.error(err) - t.deepEqual(meta.context, { winter: 'is coming' }) + t.same(meta.context, { winter: 'is coming' }) }) client.on('response', (err, { meta }) => { t.error(err) - t.deepEqual(meta.context, { winter: 'is coming' }) + t.same(meta.context, { winter: 'is coming' }) }) client.info({}, { context: { winter: 'is coming' } }, t.error) @@ -203,12 +203,12 @@ test('Request context', t => { client.on('request', (err, { meta }) => { t.error(err) - t.deepEqual(meta.context, { winter: 'is coming' }) + t.same(meta.context, { winter: 'is coming' }) }) client.on('response', (err, { meta }) => { t.error(err) - t.deepEqual(meta.context, { winter: 'is coming' }) + t.same(meta.context, { winter: 'is coming' }) }) client.info(t.error) @@ -225,12 +225,12 @@ test('Request context', t => { client.on('request', (err, { meta }) => { t.error(err) - t.deepEqual(meta.context, { winter: 'has come' }) + t.same(meta.context, { winter: 'has come' }) }) client.on('response', (err, { meta }) => { t.error(err) - t.deepEqual(meta.context, { winter: 'has come' }) + t.same(meta.context, { winter: 'has come' }) }) client.info({}, { context: { winter: 'has come' } }, t.error) @@ -245,7 +245,7 @@ test('Client name', t => { node: 'http://localhost:9200', name: 'cluster' }) - t.strictEqual(client.name, 'cluster') + t.equal(client.name, 'cluster') t.end() }) @@ -259,17 +259,17 @@ test('Client name', t => { client.on('request', (err, { meta }) => { t.error(err) - t.strictEqual(meta.name, 'cluster') + t.equal(meta.name, 'cluster') }) client.on('response', (err, { meta }) => { t.error(err) - t.strictEqual(meta.name, 'cluster') + t.equal(meta.name, 'cluster') }) client.info((err, { meta }) => { t.error(err) - t.strictEqual(meta.name, 'cluster') + t.equal(meta.name, 'cluster') }) }) @@ -284,17 +284,17 @@ test('Client name', t => { client.on('request', (err, { meta }) => { t.error(err) - t.strictEqual(meta.name, symbol) + t.equal(meta.name, symbol) }) client.on('response', (err, { meta }) => { t.error(err) - t.strictEqual(meta.name, symbol) + t.equal(meta.name, symbol) }) client.info((err, { meta }) => { t.error(err) - t.strictEqual(meta.name, symbol) + t.equal(meta.name, symbol) }) }) @@ -310,7 +310,7 @@ test('Client name', t => { client.on('sniff', (err, { meta }) => { t.error(err) - t.strictEqual(meta.name, 'elasticsearch-js') + t.equal(meta.name, 'elasticsearch-js') }) }) @@ -325,15 +325,15 @@ test('Client name', t => { }) client.on('request', (e, { meta }) => { - t.strictEqual(meta.name, 'elasticsearch-js') + t.equal(meta.name, 'elasticsearch-js') }) client.on('response', (e, { meta }) => { - t.strictEqual(meta.name, 'elasticsearch-js') + t.equal(meta.name, 'elasticsearch-js') }) client.on('sniff', (e, { meta }) => { - t.strictEqual(meta.name, 'elasticsearch-js') + t.equal(meta.name, 'elasticsearch-js') }) client.transport.request({ @@ -364,7 +364,7 @@ test('Client name', t => { client.on('resurrect', (err, meta) => { t.error(err) - t.strictEqual(meta.name, 'elasticsearch-js') + t.equal(meta.name, 'elasticsearch-js') clock.uninstall() }) @@ -392,7 +392,7 @@ test('Client name', t => { client.on('resurrect', (err, meta) => { t.error(err) - t.strictEqual(meta.name, 'child-client') + t.equal(meta.name, 'child-client') clock.uninstall() }) diff --git a/test/acceptance/proxy.test.js b/test/acceptance/proxy.test.js index 9210b6586..da54084cb 100644 --- a/test/acceptance/proxy.test.js +++ b/test/acceptance/proxy.test.js @@ -18,7 +18,7 @@ test('http-http proxy support', async t => { const server = await createServer() const proxy = await createProxy() server.on('request', (req, res) => { - t.strictEqual(req.url, '/_cluster/health') + t.equal(req.url, '/_cluster/health') res.setHeader('content-type', 'application/json') res.end(JSON.stringify({ hello: 'world' })) }) @@ -29,7 +29,7 @@ test('http-http proxy support', async t => { }) const response = await client.cluster.health() - t.deepEqual(response.body, { hello: 'world' }) + t.same(response.body, { hello: 'world' }) server.close() proxy.close() @@ -39,7 +39,7 @@ test('http-https proxy support', async t => { const server = await createSecureServer() const proxy = await createProxy() server.on('request', (req, res) => { - t.strictEqual(req.url, '/_cluster/health') + t.equal(req.url, '/_cluster/health') res.setHeader('content-type', 'application/json') res.end(JSON.stringify({ hello: 'world' })) }) @@ -50,7 +50,7 @@ test('http-https proxy support', async t => { }) const response = await client.cluster.health() - t.deepEqual(response.body, { hello: 'world' }) + t.same(response.body, { hello: 'world' }) server.close() proxy.close() @@ -60,7 +60,7 @@ test('https-http proxy support', async t => { const server = await createServer() const proxy = await createSecureProxy() server.on('request', (req, res) => { - t.strictEqual(req.url, '/_cluster/health') + t.equal(req.url, '/_cluster/health') res.setHeader('content-type', 'application/json') res.end(JSON.stringify({ hello: 'world' })) }) @@ -71,7 +71,7 @@ test('https-http proxy support', async t => { }) const response = await client.cluster.health() - t.deepEqual(response.body, { hello: 'world' }) + t.same(response.body, { hello: 'world' }) server.close() proxy.close() @@ -81,7 +81,7 @@ test('https-https proxy support', async t => { const server = await createSecureServer() const proxy = await createSecureProxy() server.on('request', (req, res) => { - t.strictEqual(req.url, '/_cluster/health') + t.equal(req.url, '/_cluster/health') res.setHeader('content-type', 'application/json') res.end(JSON.stringify({ hello: 'world' })) }) @@ -92,7 +92,7 @@ test('https-https proxy support', async t => { }) const response = await client.cluster.health() - t.deepEqual(response.body, { hello: 'world' }) + t.same(response.body, { hello: 'world' }) server.close() proxy.close() @@ -102,7 +102,7 @@ test('http basic authentication', async t => { const server = await createServer() const proxy = await createProxy() server.on('request', (req, res) => { - t.strictEqual(req.url, '/_cluster/health') + t.equal(req.url, '/_cluster/health') res.setHeader('content-type', 'application/json') res.end(JSON.stringify({ hello: 'world' })) }) @@ -117,7 +117,7 @@ test('http basic authentication', async t => { }) const response = await client.cluster.health() - t.deepEqual(response.body, { hello: 'world' }) + t.same(response.body, { hello: 'world' }) server.close() proxy.close() @@ -127,7 +127,7 @@ test('https basic authentication', async t => { const server = await createSecureServer() const proxy = await createProxy() server.on('request', (req, res) => { - t.strictEqual(req.url, '/_cluster/health') + t.equal(req.url, '/_cluster/health') res.setHeader('content-type', 'application/json') res.end(JSON.stringify({ hello: 'world' })) }) @@ -142,7 +142,7 @@ test('https basic authentication', async t => { }) const response = await client.cluster.health() - t.deepEqual(response.body, { hello: 'world' }) + t.same(response.body, { hello: 'world' }) server.close() proxy.close() diff --git a/test/acceptance/resurrect.test.js b/test/acceptance/resurrect.test.js index d9bfd6112..432929852 100644 --- a/test/acceptance/resurrect.test.js +++ b/test/acceptance/resurrect.test.js @@ -56,11 +56,11 @@ test('Should execute the recurrect API with the ping strategy', t => { client.on(events.RESURRECT, (err, meta) => { t.error(err) - t.strictEqual(meta.strategy, 'ping') - t.false(meta.isAlive) - t.strictEqual(meta.connection.id, 'node0') - t.strictEqual(meta.name, 'elasticsearch-js') - t.deepEqual(meta.request, { id: 2 }) + t.equal(meta.strategy, 'ping') + t.notOk(meta.isAlive) + t.equal(meta.connection.id, 'node0') + t.equal(meta.name, 'elasticsearch-js') + t.same(meta.request, { id: 2 }) }) q.add((q, done) => { @@ -117,14 +117,14 @@ test('Resurrect a node and handle 502/3/4 status code', t => { let idCount = 2 client.on(events.RESURRECT, (err, meta) => { t.error(err) - t.strictEqual(meta.strategy, 'ping') - t.strictEqual(meta.connection.id, 'node0') - t.strictEqual(meta.name, 'elasticsearch-js') - t.deepEqual(meta.request, { id: idCount++ }) + t.equal(meta.strategy, 'ping') + t.equal(meta.connection.id, 'node0') + t.equal(meta.name, 'elasticsearch-js') + t.same(meta.request, { id: idCount++ }) if (count < 4) { - t.false(meta.isAlive) + t.notOk(meta.isAlive) } else { - t.true(meta.isAlive) + t.ok(meta.isAlive) } }) @@ -179,11 +179,11 @@ test('Should execute the recurrect API with the optimistic strategy', t => { client.on(events.RESURRECT, (err, meta) => { t.error(err) - t.strictEqual(meta.strategy, 'optimistic') - t.true(meta.isAlive) - t.strictEqual(meta.connection.id, 'node0') - t.strictEqual(meta.name, 'elasticsearch-js') - t.deepEqual(meta.request, { id: 2 }) + t.equal(meta.strategy, 'optimistic') + t.ok(meta.isAlive) + t.equal(meta.connection.id, 'node0') + t.equal(meta.name, 'elasticsearch-js') + t.same(meta.request, { id: 2 }) }) q.add((q, done) => { diff --git a/test/acceptance/sniff.test.js b/test/acceptance/sniff.test.js index 89008ce21..ee18c9298 100644 --- a/test/acceptance/sniff.test.js +++ b/test/acceptance/sniff.test.js @@ -43,11 +43,11 @@ test('Should update the connection pool', t => { const client = new Client({ node: nodes[Object.keys(nodes)[0]].url }) - t.strictEqual(client.connectionPool.size, 1) + t.equal(client.connectionPool.size, 1) client.on(events.SNIFF, (err, request) => { t.error(err) - t.strictEqual( + t.equal( request.meta.sniff.reason, Transport.sniffReasons.DEFAULT ) @@ -56,14 +56,14 @@ test('Should update the connection pool', t => { // run the sniffer client.transport.sniff((err, hosts) => { t.error(err) - t.strictEqual(hosts.length, 4) + t.equal(hosts.length, 4) const ids = Object.keys(nodes) for (let i = 0; i < hosts.length; i++) { const id = ids[i] // the first node will be an update of the existing one if (id === 'node0') { - t.deepEqual(hosts[i], { + t.same(hosts[i], { url: new URL(nodes[id].url), id: id, roles: { @@ -74,7 +74,7 @@ test('Should update the connection pool', t => { } }) } else { - t.deepEqual(hosts[i], { + t.same(hosts[i], { url: new URL(nodes[id].url), id: id, roles: { @@ -90,7 +90,7 @@ test('Should update the connection pool', t => { } } - t.strictEqual(client.connectionPool.size, 4) + t.equal(client.connectionPool.size, 4) }) t.teardown(shutdown) }) @@ -103,11 +103,11 @@ test('Should handle hostnames in publish_address', t => { const client = new Client({ node: nodes[Object.keys(nodes)[0]].url }) - t.strictEqual(client.connectionPool.size, 1) + t.equal(client.connectionPool.size, 1) client.on(events.SNIFF, (err, request) => { t.error(err) - t.strictEqual( + t.equal( request.meta.sniff.reason, Transport.sniffReasons.DEFAULT ) @@ -116,14 +116,14 @@ test('Should handle hostnames in publish_address', t => { // run the sniffer client.transport.sniff((err, hosts) => { t.error(err) - t.strictEqual(hosts.length, 4) + t.equal(hosts.length, 4) for (let i = 0; i < hosts.length; i++) { // the first node will be an update of the existing one - t.strictEqual(hosts[i].url.hostname, 'localhost') + t.equal(hosts[i].url.hostname, 'localhost') } - t.strictEqual(client.connectionPool.size, 4) + t.equal(client.connectionPool.size, 4) }) t.teardown(shutdown) }) @@ -144,21 +144,21 @@ test('Sniff interval', t => { client.on(events.SNIFF, (err, request) => { t.error(err) const { hosts, reason } = request.meta.sniff - t.strictEqual( + t.equal( client.connectionPool.size, hosts.length ) - t.strictEqual(reason, Transport.sniffReasons.SNIFF_INTERVAL) + t.equal(reason, Transport.sniffReasons.SNIFF_INTERVAL) }) - t.strictEqual(client.connectionPool.size, 1) + t.equal(client.connectionPool.size, 1) q.add((q, done) => { clock.tick(51) client.info(err => { t.error(err) waitSniffEnd(() => { - t.strictEqual(client.connectionPool.size, 4) + t.equal(client.connectionPool.size, 4) done() }) }) @@ -173,7 +173,7 @@ test('Sniff interval', t => { client.info(err => { t.error(err) waitSniffEnd(() => { - t.strictEqual(client.connectionPool.size, 3) + t.equal(client.connectionPool.size, 3) done() }) }) @@ -208,14 +208,14 @@ test('Sniff on start', t => { client.on(events.SNIFF, (err, request) => { t.error(err) const { hosts, reason } = request.meta.sniff - t.strictEqual( + t.equal( client.connectionPool.size, hosts.length ) - t.strictEqual(reason, Transport.sniffReasons.SNIFF_ON_START) + t.equal(reason, Transport.sniffReasons.SNIFF_ON_START) }) - t.strictEqual(client.connectionPool.size, 1) + t.equal(client.connectionPool.size, 1) t.teardown(shutdown) }) }) @@ -238,10 +238,10 @@ test('Should not close living connections', t => { Connection: MyConnection }) - t.strictEqual(client.connectionPool.size, 1) + t.equal(client.connectionPool.size, 1) client.transport.sniff((err, hosts) => { t.error(err) - t.strictEqual( + t.equal( client.connectionPool.size, hosts.length ) @@ -276,16 +276,16 @@ test('Sniff on connection fault', t => { Connection: MyConnection }) - t.strictEqual(client.connectionPool.size, 2) + t.equal(client.connectionPool.size, 2) // this event will be triggered by the connection fault client.on(events.SNIFF, (err, request) => { t.error(err) const { hosts, reason } = request.meta.sniff - t.strictEqual( + t.equal( client.connectionPool.size, hosts.length ) - t.strictEqual(reason, Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) + t.equal(reason, Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) }) client.info((err, result) => { diff --git a/test/integration/helpers/bulk.test.js b/test/integration/helpers/bulk.test.js index 1966f39b1..011f524c3 100644 --- a/test/integration/helpers/bulk.test.js +++ b/test/integration/helpers/bulk.test.js @@ -102,9 +102,9 @@ test('bulk index with custom id', async t => { id: '19273860' // id of document n° 4242 }) - t.strictEqual(body._index, INDEX) - t.strictEqual(body._id, '19273860') - t.strictEqual(body._source.id, '19273860') + t.equal(body._index, INDEX) + t.equal(body._id, '19273860') + t.equal(body._source.id, '19273860') }) test('abort the operation on document drop', async t => { @@ -113,9 +113,9 @@ test('abort the operation on document drop', async t => { datasource: stream.pipe(split(JSON.parse)), concurrency: 1, onDrop (doc) { - t.strictEqual(doc.status, 400) - t.strictEqual(doc.error.type, 'mapper_parsing_exception') - t.strictEqual(doc.document.id, '45924372') + t.equal(doc.status, 400) + t.equal(doc.error.type, 'mapper_parsing_exception') + t.equal(doc.document.id, '45924372') b.abort() }, onDocument (doc) { @@ -135,7 +135,7 @@ test('abort the operation on document drop', async t => { const result = await b t.type(result.time, 'number') t.type(result.bytes, 'number') - t.strictEqual(result.total - 1, result.successful) + t.equal(result.total - 1, result.successful) t.match(result, { retry: 0, failed: 1, diff --git a/test/integration/helpers/msearch.test.js b/test/integration/helpers/msearch.test.js index e387b4fa9..c9c726ecc 100644 --- a/test/integration/helpers/msearch.test.js +++ b/test/integration/helpers/msearch.test.js @@ -62,7 +62,7 @@ test('Basic', t => { { query: { match: { title: 'javascript' } } }, (err, result) => { t.error(err) - t.strictEqual(result.body.hits.total.value, 106) + t.equal(result.body.hits.total.value, 106) } ) @@ -71,7 +71,7 @@ test('Basic', t => { { query: { match: { title: 'ruby' } } }, (err, result) => { t.error(err) - t.strictEqual(result.body.hits.total.value, 29) + t.equal(result.body.hits.total.value, 29) } ) @@ -87,7 +87,7 @@ test('Bad request', t => { { query: { match: { title: 'javascript' } } }, (err, result) => { t.error(err) - t.strictEqual(result.body.hits.total.value, 106) + t.equal(result.body.hits.total.value, 106) } ) @@ -95,7 +95,7 @@ test('Bad request', t => { { index: INDEX }, { query: { foo: { title: 'ruby' } } }, (err, result) => { - t.true(err instanceof errors.ResponseError) + t.ok(err instanceof errors.ResponseError) } ) @@ -112,7 +112,7 @@ test('Send multiple request concurrently over the concurrency limit', t => { { query: { match: { title: 'javascript' } } }, (err, result) => { t.error(err) - t.strictEqual(result.body.hits.total.value, 106) + t.equal(result.body.hits.total.value, 106) } ) } diff --git a/test/integration/helpers/scroll.test.js b/test/integration/helpers/scroll.test.js index e7777a4b7..e197ce21a 100644 --- a/test/integration/helpers/scroll.test.js +++ b/test/integration/helpers/scroll.test.js @@ -69,10 +69,10 @@ test('search helper', async t => { for await (const search of scrollSearch) { count += 1 for (const doc of search.documents) { - t.true(doc.title.toLowerCase().includes('javascript')) + t.ok(doc.title.toLowerCase().includes('javascript')) } } - t.strictEqual(count, 11) + t.equal(count, 11) }) test('clear a scroll search', async t => { @@ -94,7 +94,7 @@ test('clear a scroll search', async t => { search.clear() } } - t.strictEqual(count, 2) + t.equal(count, 2) }) test('scroll documents', async t => { @@ -112,7 +112,7 @@ test('scroll documents', async t => { let count = 0 for await (const doc of scrollSearch) { count += 1 - t.true(doc.title.toLowerCase().includes('javascript')) + t.ok(doc.title.toLowerCase().includes('javascript')) } - t.strictEqual(count, 106) + t.equal(count, 106) }) diff --git a/test/integration/helpers/search.test.js b/test/integration/helpers/search.test.js index 247fc9ac9..d4aa57c9a 100644 --- a/test/integration/helpers/search.test.js +++ b/test/integration/helpers/search.test.js @@ -64,8 +64,8 @@ test('search helper', async t => { } } }) - t.strictEqual(results.length, 10) + t.equal(results.length, 10) for (const result of results) { - t.true(result.title.toLowerCase().includes('javascript')) + t.ok(result.title.toLowerCase().includes('javascript')) } }) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 7dbd7c158..ef577210a 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -594,7 +594,7 @@ function match (val1, val2, action) { // tap.match(val1, new RegExp(regStr, 'm'), `should match pattern provided: ${val2}, action: ${JSON.stringify(action)}`) // everything else } else { - assert.strictEqual(val1, val2, `should be equal: ${val1} - ${val2}, action: ${JSON.stringify(action)}`) + assert.equal(val1, val2, `should be equal: ${val1} - ${val2}, action: ${JSON.stringify(action)}`) } } @@ -654,9 +654,9 @@ function gte (val1, val2) { */ function length (val, len) { if (typeof val === 'string' || Array.isArray(val)) { - assert.strictEqual(val.length, len) + assert.equal(val.length, len) } else if (typeof val === 'object' && val !== null) { - assert.strictEqual(Object.keys(val).length, len) + assert.equal(Object.keys(val).length, len) } else { assert.fail(`length: the given value is invalid: ${val}`) } diff --git a/test/unit/api-async.js b/test/unit/api-async.js index 437c00abf..fb0bb1b80 100644 --- a/test/unit/api-async.js +++ b/test/unit/api-async.js @@ -42,7 +42,7 @@ function runAsyncTest (test) { type: 'doc', q: 'foo:bar' }) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) } catch (err) { t.fail(err) } diff --git a/test/unit/api.test.js b/test/unit/api.test.js index b5a7fbb57..667ec66ab 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -41,7 +41,7 @@ test('Basic (callback)', t => { q: 'foo:bar' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -66,7 +66,7 @@ test('Basic (promises)', t => { q: 'foo:bar' }) .then(({ body }) => { - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) .catch(t.fail) @@ -169,7 +169,7 @@ test('Abort method (callback)', t => { q: 'foo:bar' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) @@ -197,7 +197,7 @@ test('Abort method (promises)', t => { request .then(({ body }) => { - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) .catch(t.fail) @@ -226,7 +226,7 @@ test('Basic (options and callback)', t => { requestTimeout: 10000 }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -253,7 +253,7 @@ test('Basic (options and promises)', t => { requestTimeout: 10000 }) .then(({ body }) => { - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) .catch(t.fail) @@ -264,7 +264,7 @@ test('If the API uses the same key for both url and query parameter, the url sho t.plan(2) function handler (req, res) { - t.strictEqual(req.url, '/index/_bulk') + t.equal(req.url, '/index/_bulk') res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } diff --git a/test/unit/base-connection-pool.test.js b/test/unit/base-connection-pool.test.js index 268f68e70..6fe8c7206 100644 --- a/test/unit/base-connection-pool.test.js +++ b/test/unit/base-connection-pool.test.js @@ -30,7 +30,7 @@ test('API', t => { const href = 'http://localhost:9200/' pool.addConnection(href) t.ok(pool.connections.find(c => c.id === href) instanceof Connection) - t.strictEqual(pool.connections.find(c => c.id === href).status, Connection.statuses.ALIVE) + t.equal(pool.connections.find(c => c.id === href).status, Connection.statuses.ALIVE) t.end() }) @@ -42,7 +42,7 @@ test('API', t => { pool.addConnection(href) t.fail('Should throw') } catch (err) { - t.is(err.message, `Connection with id '${href}' is already present`) + t.equal(err.message, `Connection with id '${href}' is already present`) } t.end() }) @@ -52,8 +52,8 @@ test('API', t => { const href = 'http://us"er:p@assword@localhost:9200/' pool.addConnection(href) const conn = pool.connections[0] - t.strictEqual(conn.url.username, 'us%22er') - t.strictEqual(conn.url.password, 'p%40assword') + t.equal(conn.url.username, 'us%22er') + t.equal(conn.url.password, 'p%40assword') t.match(conn.headers, { authorization: 'Basic ' + Buffer.from('us"er:p@assword').toString('base64') }) @@ -66,7 +66,7 @@ test('API', t => { let connection = pool.addConnection(href) t.same(pool.markDead(connection), pool) connection = pool.connections.find(c => c.id === href) - t.strictEqual(connection.status, Connection.statuses.ALIVE) + t.equal(connection.status, Connection.statuses.ALIVE) t.end() }) @@ -76,7 +76,7 @@ test('API', t => { let connection = pool.addConnection(href) t.same(pool.markAlive(connection), pool) connection = pool.connections.find(c => c.id === href) - t.strictEqual(connection.status, Connection.statuses.ALIVE) + t.equal(connection.status, Connection.statuses.ALIVE) t.end() }) @@ -88,7 +88,7 @@ test('API', t => { pool.getConnection() t.fail('Should fail') } catch (err) { - t.is(err.message, 'getConnection must be implemented') + t.equal(err.message, 'getConnection must be implemented') } t.end() }) @@ -98,7 +98,7 @@ test('API', t => { const href = 'http://localhost:9200/' const connection = pool.addConnection(href) pool.removeConnection(connection) - t.strictEqual(pool.size, 0) + t.equal(pool.size, 0) t.end() }) @@ -107,7 +107,7 @@ test('API', t => { pool.addConnection('http://localhost:9200/') pool.addConnection('http://localhost:9201/') pool.empty(() => { - t.strictEqual(pool.size, 0) + t.equal(pool.size, 0) t.end() }) }) @@ -115,7 +115,7 @@ test('API', t => { t.test('urlToHost', t => { const pool = new BaseConnectionPool({ Connection }) const url = 'http://localhost:9200' - t.deepEqual( + t.same( pool.urlToHost(url), { url: new URL(url) } ) @@ -140,7 +140,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: { @@ -160,8 +160,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, '127.0.0.1:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, '127.0.0.1:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, '127.0.0.1:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, '127.0.0.1:9201') t.end() }) @@ -182,7 +182,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://[::1]:9200'), id: 'a1', roles: { @@ -202,8 +202,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, '[::1]:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, '[::1]:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, '[::1]:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, '[::1]:9201') t.end() }) @@ -224,7 +224,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://example.com:9200'), id: 'a1', roles: { @@ -244,8 +244,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') t.end() }) @@ -266,7 +266,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://example.com:9200'), id: 'a1', roles: { @@ -286,8 +286,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') t.end() }) @@ -308,8 +308,8 @@ test('API', t => { } } - t.strictEqual(pool.nodesToHost(nodes, 'https:')[0].url.protocol, 'https:') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.protocol, 'http:') + t.equal(pool.nodesToHost(nodes, 'https:')[0].url.protocol, 'https:') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.protocol, 'http:') t.end() }) @@ -425,13 +425,13 @@ test('API', t => { // roles will never be updated, we only use it to do // a dummy check to see if the connection has been updated - t.deepEqual(pool.connections.find(c => c.id === 'a1').roles, { + t.same(pool.connections.find(c => c.id === 'a1').roles, { master: true, data: true, ingest: true, ml: false }) - t.strictEqual(pool.connections.find(c => c.id === 'http://127.0.0.1:9200/'), undefined) + t.equal(pool.connections.find(c => c.id === 'http://127.0.0.1:9200/'), undefined) }) t.test('Add a new connection', t => { @@ -480,9 +480,9 @@ test('API', t => { roles: null }]) - t.false(pool.connections.find(c => c.id === 'a1')) - t.true(pool.connections.find(c => c.id === 'a2')) - t.true(pool.connections.find(c => c.id === 'a3')) + t.notOk(pool.connections.find(c => c.id === 'a1')) + t.ok(pool.connections.find(c => c.id === 'a2')) + t.ok(pool.connections.find(c => c.id === 'a3')) }) t.end() @@ -497,7 +497,7 @@ test('API', t => { pool.createConnection('http://localhost:9200') t.fail('Should throw') } catch (err) { - t.is(err.message, 'Connection with id \'http://localhost:9200/\' is already present') + t.equal(err.message, 'Connection with id \'http://localhost:9200/\' is already present') } }) diff --git a/test/unit/child.test.js b/test/unit/child.test.js index 1cb3d2b66..626d8941b 100644 --- a/test/unit/child.test.js +++ b/test/unit/child.test.js @@ -76,7 +76,7 @@ test('Should create a child client (timeout check)', t => { client.info((err, res) => { t.error(err) child.info((err, res) => { - t.true(err instanceof errors.TimeoutError) + t.ok(err instanceof errors.TimeoutError) server.stop() }) }) @@ -238,7 +238,7 @@ test('Should create a child client (generateRequestId check)', t => { let count = 0 client.on('request', (err, { meta }) => { t.error(err) - t.strictEqual( + t.equal( meta.request.id, count++ === 0 ? 'trace-1-0' : 'trace-2-0' ) @@ -263,13 +263,13 @@ test('Should create a child client (name check)', t => { name: 'child' }) - t.strictEqual(client.name, 'parent') - t.strictEqual(child.name, 'child') + t.equal(client.name, 'parent') + t.equal(child.name, 'child') let count = 0 client.on('request', (err, { meta }) => { t.error(err) - t.strictEqual( + t.equal( meta.name, count++ === 0 ? 'parent' : 'child' ) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index a0a5c5d72..9c2c551ba 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -111,7 +111,7 @@ test('Configure host', t => { resurrectTimeout: 0 }) - t.deepEqual(pool.connections.find(c => c.id === 'node').roles, { + t.same(pool.connections.find(c => c.id === 'node').roles, { master: true, data: false, ingest: false, @@ -152,7 +152,7 @@ test('Configure host', t => { resurrectTimeout: 0 }) - t.deepEqual(pool.connections.find(c => c.id === 'node1').roles, { + t.same(pool.connections.find(c => c.id === 'node1').roles, { master: true, data: false, ingest: false, @@ -167,7 +167,7 @@ test('Configure host', t => { resurrectTimeout: 0 }) - t.deepEqual(pool.connections.find(c => c.id === 'node2').roles, { + t.same(pool.connections.find(c => c.id === 'node2').roles, { master: false, data: true, ingest: false, @@ -226,7 +226,7 @@ test('Authentication', t => { client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -250,7 +250,7 @@ test('Authentication', t => { client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -278,7 +278,7 @@ test('Authentication', t => { client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -307,12 +307,12 @@ test('Authentication', t => { } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) first = false client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -346,12 +346,12 @@ test('Authentication', t => { } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) first = false client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -383,7 +383,7 @@ test('Authentication', t => { client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -410,7 +410,7 @@ test('Authentication', t => { client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -439,12 +439,12 @@ test('Authentication', t => { } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) first = false client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -477,12 +477,12 @@ test('Authentication', t => { } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) first = false client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -510,7 +510,7 @@ test('Authentication', t => { client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -539,7 +539,7 @@ test('Authentication', t => { client.info((err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -575,7 +575,7 @@ test('Custom headers per request', t => { } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -625,8 +625,8 @@ test('Extend client APIs', t => { const client = new Client({ node: 'http://localhost:9200' }) client.extend('method', ({ makeRequest, result, ConfigurationError }) => { t.type(makeRequest, 'function') - t.true(new ConfigurationError() instanceof Error) - t.deepEqual(result, { + t.ok(new ConfigurationError() instanceof Error) + t.same(result, { body: null, statusCode: null, headers: null, @@ -634,8 +634,8 @@ test('Extend client APIs', t => { }) return (params, options) => { - t.deepEqual(params, { you_know: 'for search' }) - t.deepEqual(options, { winter: 'is coming' }) + t.same(params, { you_know: 'for search' }) + t.same(options, { winter: 'is coming' }) } }) @@ -651,8 +651,8 @@ test('Extend client APIs', t => { const client = new Client({ node: 'http://localhost:9200' }) client.extend('namespace.method', ({ makeRequest, result, ConfigurationError }) => { t.type(makeRequest, 'function') - t.true(new ConfigurationError() instanceof Error) - t.deepEqual(result, { + t.ok(new ConfigurationError() instanceof Error) + t.same(result, { body: null, statusCode: null, headers: null, @@ -660,8 +660,8 @@ test('Extend client APIs', t => { }) return (params, options) => { - t.deepEqual(params, { you_know: 'for search' }) - t.deepEqual(options, { winter: 'is coming' }) + t.same(params, { you_know: 'for search' }) + t.same(options, { winter: 'is coming' }) } }) @@ -677,8 +677,8 @@ test('Extend client APIs', t => { const client = new Client({ node: 'http://localhost:9200' }) client.extend('namespace.method1', ({ makeRequest, result, ConfigurationError }) => { t.type(makeRequest, 'function') - t.true(new ConfigurationError() instanceof Error) - t.deepEqual(result, { + t.ok(new ConfigurationError() instanceof Error) + t.same(result, { body: null, statusCode: null, headers: null, @@ -686,15 +686,15 @@ test('Extend client APIs', t => { }) return (params, options) => { - t.deepEqual(params, { you_know: 'for search' }) - t.deepEqual(options, { winter: 'is coming' }) + t.same(params, { you_know: 'for search' }) + t.same(options, { winter: 'is coming' }) } }) client.extend('namespace.method2', ({ makeRequest, result, ConfigurationError }) => { t.type(makeRequest, 'function') - t.true(new ConfigurationError() instanceof Error) - t.deepEqual(result, { + t.ok(new ConfigurationError() instanceof Error) + t.same(result, { body: null, statusCode: null, headers: null, @@ -702,8 +702,8 @@ test('Extend client APIs', t => { }) return (params, options) => { - t.deepEqual(params, { you_know: 'for search' }) - t.deepEqual(options, { winter: 'is coming' }) + t.same(params, { you_know: 'for search' }) + t.same(options, { winter: 'is coming' }) } }) @@ -726,7 +726,7 @@ test('Extend client APIs', t => { client.extend('index', () => {}) t.fail('Should throw') } catch (err) { - t.is(err.message, 'The method "index" already exists') + t.equal(err.message, 'The method "index" already exists') } }) @@ -738,7 +738,7 @@ test('Extend client APIs', t => { client.extend('indices.delete', () => {}) t.fail('Should throw') } catch (err) { - t.is(err.message, 'The method "delete" already exists on namespace "indices"') + t.equal(err.message, 'The method "delete" already exists on namespace "indices"') } }) @@ -769,8 +769,8 @@ test('Extend client APIs', t => { class MyTransport extends Transport { request (params, options) { - t.deepEqual(params, { you_know: 'for search' }) - t.deepEqual(options, { winter: 'is coming' }) + t.same(params, { you_know: 'for search' }) + t.same(options, { winter: 'is coming' }) } } @@ -803,7 +803,7 @@ test('Extend client APIs', t => { { winter: 'is coming' }, (err, res) => { t.error(err) - t.deepEqual(res, { hello: 'world' }) + t.same(res, { hello: 'world' }) } ) }) @@ -825,7 +825,7 @@ test('Extend client APIs', t => { { you_know: 'for search' }, { winter: 'is coming' } ) - .then(res => t.deepEqual(res, { hello: 'world' })) + .then(res => t.same(res, { hello: 'world' })) .catch(err => t.fail(err)) }) @@ -863,9 +863,9 @@ test('Elastic cloud config', t => { } }) - t.strictEqual(client.transport.compression, 'gzip') - t.strictEqual(client.transport.suggestCompression, true) - t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) + t.equal(client.transport.compression, 'gzip') + t.equal(client.transport.suggestCompression, true) + t.same(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) }) t.test('Without kibana component', t => { @@ -898,9 +898,9 @@ test('Elastic cloud config', t => { } }) - t.strictEqual(client.transport.compression, 'gzip') - t.strictEqual(client.transport.suggestCompression, true) - t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) + t.equal(client.transport.compression, 'gzip') + t.equal(client.transport.suggestCompression, true) + t.same(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) }) t.test('Auth as separate option', t => { @@ -935,9 +935,9 @@ test('Elastic cloud config', t => { } }) - t.strictEqual(client.transport.compression, 'gzip') - t.strictEqual(client.transport.suggestCompression, true) - t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) + t.equal(client.transport.compression, 'gzip') + t.equal(client.transport.suggestCompression, true) + t.same(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) }) t.test('ApiKey should take precedence over basic auth', t => { @@ -973,9 +973,9 @@ test('Elastic cloud config', t => { } }) - t.strictEqual(client.transport.compression, 'gzip') - t.strictEqual(client.transport.suggestCompression, true) - t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) + t.equal(client.transport.compression, 'gzip') + t.equal(client.transport.suggestCompression, true) + t.same(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) }) t.test('Override default options', t => { @@ -995,9 +995,9 @@ test('Elastic cloud config', t => { }) t.ok(client.connectionPool instanceof CloudConnectionPool) - t.strictEqual(client.transport.compression, false) - t.strictEqual(client.transport.suggestCompression, false) - t.deepEqual(client.connectionPool._ssl, { secureProtocol: 'TLSv1_1_method' }) + t.equal(client.transport.compression, false) + t.equal(client.transport.suggestCompression, false) + t.same(client.connectionPool._ssl, { secureProtocol: 'TLSv1_1_method' }) }) t.end() @@ -1008,7 +1008,7 @@ test('Opaque Id support', t => { t.plan(3) function handler (req, res) { - t.strictEqual(req.headers['x-opaque-id'], undefined) + t.equal(req.headers['x-opaque-id'], undefined) res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } @@ -1023,7 +1023,7 @@ test('Opaque Id support', t => { q: 'foo:bar' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1033,7 +1033,7 @@ test('Opaque Id support', t => { t.plan(3) function handler (req, res) { - t.strictEqual(req.headers['x-opaque-id'], 'bar') + t.equal(req.headers['x-opaque-id'], 'bar') res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } @@ -1050,7 +1050,7 @@ test('Opaque Id support', t => { opaqueId: 'bar' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1060,7 +1060,7 @@ test('Opaque Id support', t => { t.plan(3) function handler (req, res) { - t.strictEqual(req.headers['x-opaque-id'], 'foo-bar') + t.equal(req.headers['x-opaque-id'], 'foo-bar') res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } @@ -1078,7 +1078,7 @@ test('Opaque Id support', t => { opaqueId: 'bar' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1091,8 +1091,8 @@ test('Correctly handles the same header cased differently', t => { t.plan(4) function handler (req, res) { - t.strictEqual(req.headers.authorization, 'Basic foobar') - t.strictEqual(req.headers.foo, 'baz') + t.equal(req.headers.authorization, 'Basic foobar') + t.equal(req.headers.foo, 'baz') res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } @@ -1119,7 +1119,7 @@ test('Correctly handles the same header cased differently', t => { } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1144,7 +1144,7 @@ test('Random selector', t => { q: 'foo:bar' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1154,7 +1154,7 @@ test('Disable keep alive agent', t => { t.plan(3) function handler (req, res) { - t.strictEqual(req.headers.connection, 'close') + t.equal(req.headers.connection, 'close') res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } @@ -1170,7 +1170,7 @@ test('Disable keep alive agent', t => { q: 'foo:bar' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1184,7 +1184,7 @@ test('name property as string', t => { name: 'client-name' }) - t.strictEqual(client.name, 'client-name') + t.equal(client.name, 'client-name') }) test('name property as symbol', t => { @@ -1196,7 +1196,7 @@ test('name property as symbol', t => { name: symbol }) - t.strictEqual(client.name, symbol) + t.equal(client.name, symbol) }) // The nodejs http agent will try to wait for the whole @@ -1218,8 +1218,8 @@ test('Bad content length', t => { const client = new Client({ node: `http://localhost:${port}`, maxRetries: 1 }) client.info((err, { body }) => { t.ok(err instanceof errors.ConnectionError) - t.is(err.message, 'Response aborted while reading the body') - t.strictEqual(count, 2) + t.equal(err.message, 'Response aborted while reading the body') + t.equal(count, 2) server.stop() }) }) @@ -1244,8 +1244,8 @@ test('Socket destryed while reading the body', t => { const client = new Client({ node: `http://localhost:${port}`, maxRetries: 1 }) client.info((err, { body }) => { t.ok(err instanceof errors.ConnectionError) - t.is(err.message, 'Response aborted while reading the body') - t.strictEqual(count, 2) + t.equal(err.message, 'Response aborted while reading the body') + t.equal(count, 2) server.stop() }) }) @@ -1274,8 +1274,8 @@ test('Content length too big (buffer)', t => { const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection }) client.info((err, result) => { t.ok(err instanceof errors.RequestAbortedError) - t.is(err.message, `The content length (${buffer.constants.MAX_LENGTH + 10}) is bigger than the maximum allowed buffer (${buffer.constants.MAX_LENGTH})`) - t.strictEqual(result.meta.attempts, 0) + t.equal(err.message, `The content length (${buffer.constants.MAX_LENGTH + 10}) is bigger than the maximum allowed buffer (${buffer.constants.MAX_LENGTH})`) + t.equal(result.meta.attempts, 0) }) }) @@ -1301,8 +1301,8 @@ test('Content length too big (string)', t => { const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection }) client.info((err, result) => { t.ok(err instanceof errors.RequestAbortedError) - t.is(err.message, `The content length (${buffer.constants.MAX_STRING_LENGTH + 10}) is bigger than the maximum allowed string (${buffer.constants.MAX_STRING_LENGTH})`) - t.strictEqual(result.meta.attempts, 0) + t.equal(err.message, `The content length (${buffer.constants.MAX_STRING_LENGTH + 10}) is bigger than the maximum allowed string (${buffer.constants.MAX_STRING_LENGTH})`) + t.equal(result.meta.attempts, 0) }) }) @@ -1389,7 +1389,7 @@ test('Prototype poisoning protection enabled by default', t => { }) client.info((err, result) => { - t.true(err instanceof errors.DeserializationError) + t.ok(err instanceof errors.DeserializationError) }) }) diff --git a/test/unit/cloud-connection-pool.test.js b/test/unit/cloud-connection-pool.test.js index ccefcc337..76c135509 100644 --- a/test/unit/cloud-connection-pool.test.js +++ b/test/unit/cloud-connection-pool.test.js @@ -33,7 +33,7 @@ test('Should expose a cloudConnection property', t => { test('Get connection should always return cloudConnection', t => { const pool = new CloudConnectionPool({ Connection }) const conn = pool.addConnection('http://localhost:9200/') - t.deepEqual(pool.getConnection(), conn) + t.same(pool.getConnection(), conn) t.end() }) @@ -42,7 +42,7 @@ test('pool.empty should reset cloudConnection', t => { pool.addConnection('http://localhost:9200/') t.ok(pool.cloudConnection instanceof Connection) pool.empty(() => { - t.strictEqual(pool.cloudConnection, null) + t.equal(pool.cloudConnection, null) t.end() }) }) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 6569f59f2..7a75879dd 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -32,8 +32,8 @@ test('API', t => { const href = 'http://localhost:9200/' pool.addConnection(href) t.ok(pool.connections.find(c => c.id === href) instanceof Connection) - t.strictEqual(pool.connections.find(c => c.id === href).status, Connection.statuses.ALIVE) - t.deepEqual(pool.dead, []) + t.equal(pool.connections.find(c => c.id === href).status, Connection.statuses.ALIVE) + t.same(pool.dead, []) t.end() }) @@ -45,7 +45,7 @@ test('API', t => { pool.addConnection(href) t.fail('Should throw') } catch (err) { - t.is(err.message, `Connection with id '${href}' is already present`) + t.equal(err.message, `Connection with id '${href}' is already present`) } t.end() }) @@ -55,8 +55,8 @@ test('API', t => { const href = 'http://us"er:p@assword@localhost:9200/' pool.addConnection(href) const conn = pool.getConnection() - t.strictEqual(conn.url.username, 'us%22er') - t.strictEqual(conn.url.password, 'p%40assword') + t.equal(conn.url.username, 'us%22er') + t.equal(conn.url.password, 'p%40assword') t.match(conn.headers, { authorization: 'Basic ' + Buffer.from('us"er:p@assword').toString('base64') }) @@ -69,9 +69,9 @@ test('API', t => { let connection = pool.addConnection(href) pool.markDead(connection) connection = pool.connections.find(c => c.id === href) - t.strictEqual(connection.deadCount, 1) - t.true(connection.resurrectTimeout > 0) - t.deepEqual(pool.dead, [href]) + t.equal(connection.deadCount, 1) + t.ok(connection.resurrectTimeout > 0) + t.same(pool.dead, [href]) t.end() }) @@ -84,7 +84,7 @@ test('API', t => { pool.markDead(conn2) setTimeout(() => { pool.markDead(conn1) - t.deepEqual(pool.dead, [href2, href1]) + t.same(pool.dead, [href2, href1]) t.end() }, 10) }) @@ -93,7 +93,7 @@ test('API', t => { const pool = new ConnectionPool({ Connection, sniffEnabled: true }) pool.addConnection('http://localhost:9200/') pool.markDead({ id: 'foo-bar' }) - t.deepEqual(pool.dead, []) + t.same(pool.dead, []) t.end() }) @@ -104,10 +104,10 @@ test('API', t => { pool.markDead(connection) pool.markAlive(connection) connection = pool.connections.find(c => c.id === href) - t.strictEqual(connection.deadCount, 0) - t.strictEqual(connection.resurrectTimeout, 0) - t.strictEqual(connection.status, Connection.statuses.ALIVE) - t.deepEqual(pool.dead, []) + t.equal(connection.deadCount, 0) + t.equal(connection.resurrectTimeout, 0) + t.equal(connection.status, Connection.statuses.ALIVE) + t.same(pool.dead, []) t.end() }) @@ -129,12 +129,12 @@ test('API', t => { name: 'elasticsearch-js' } pool.resurrect(opts, (isAlive, connection) => { - t.true(isAlive) + t.ok(isAlive) connection = pool.connections.find(c => c.id === connection.id) - t.strictEqual(connection.deadCount, 0) - t.strictEqual(connection.resurrectTimeout, 0) - t.strictEqual(connection.status, Connection.statuses.ALIVE) - t.deepEqual(pool.dead, []) + t.equal(connection.deadCount, 0) + t.equal(connection.resurrectTimeout, 0) + t.equal(connection.status, Connection.statuses.ALIVE) + t.same(pool.dead, []) t.end() }) }) @@ -155,12 +155,12 @@ test('API', t => { name: 'elasticsearch-js' } pool.resurrect(opts, (isAlive, connection) => { - t.false(isAlive) + t.notOk(isAlive) connection = pool.connections.find(c => c.id === connection.id) - t.strictEqual(connection.deadCount, 2) - t.true(connection.resurrectTimeout > 0) - t.strictEqual(connection.status, Connection.statuses.DEAD) - t.deepEqual(pool.dead, [href]) + t.equal(connection.deadCount, 2) + t.ok(connection.resurrectTimeout > 0) + t.equal(connection.status, Connection.statuses.DEAD) + t.same(pool.dead, [href]) t.end() }) }) @@ -183,12 +183,12 @@ test('API', t => { name: 'elasticsearch-js' } pool.resurrect(opts, (isAlive, connection) => { - t.true(isAlive) + t.ok(isAlive) connection = pool.connections.find(c => c.id === connection.id) - t.strictEqual(connection.deadCount, 1) - t.true(connection.resurrectTimeout > 0) - t.strictEqual(connection.status, Connection.statuses.ALIVE) - t.deepEqual(pool.dead, []) + t.equal(connection.deadCount, 1) + t.ok(connection.resurrectTimeout > 0) + t.equal(connection.status, Connection.statuses.ALIVE) + t.same(pool.dead, []) t.end() }) }) @@ -211,10 +211,10 @@ test('API', t => { t.ok(isAlive === null) t.ok(connection === null) connection = pool.connections.find(c => c.id === href) - t.strictEqual(connection.deadCount, 1) - t.true(connection.resurrectTimeout > 0) - t.strictEqual(connection.status, Connection.statuses.DEAD) - t.deepEqual(pool.dead, [href]) + t.equal(connection.deadCount, 1) + t.ok(connection.resurrectTimeout > 0) + t.equal(connection.status, Connection.statuses.DEAD) + t.same(pool.dead, [href]) t.end() }) }) @@ -238,7 +238,7 @@ test('API', t => { pool.addConnection([href1, href2]) const filter = node => node.id === href1 - t.strictEqual(pool.getConnection({ filter }).id, href1) + t.equal(pool.getConnection({ filter }).id, href1) t.end() }) @@ -266,7 +266,7 @@ test('API', t => { pool.markDead(conn) const filter = node => { - t.strictEqual(node.status, Connection.statuses.ALIVE) + t.equal(node.status, Connection.statuses.ALIVE) return true } pool.getConnection({ filter }) @@ -282,7 +282,7 @@ test('API', t => { pool.markDead(conn2) const conn = pool.getConnection() t.ok(conn instanceof Connection) - t.is(conn.status, 'dead') + t.equal(conn.status, 'dead') t.end() }) @@ -295,7 +295,7 @@ test('API', t => { const connection = pool.addConnection(href) t.ok(pool.getConnection() instanceof Connection) pool.removeConnection(connection) - t.strictEqual(pool.getConnection(), null) + t.equal(pool.getConnection(), null) t.end() }) @@ -304,8 +304,8 @@ test('API', t => { pool.addConnection('http://localhost:9200/') pool.addConnection('http://localhost:9201/') pool.empty(() => { - t.strictEqual(pool.size, 0) - t.deepEqual(pool.dead, []) + t.equal(pool.size, 0) + t.same(pool.dead, []) t.end() }) }) @@ -313,7 +313,7 @@ test('API', t => { t.test('urlToHost', t => { const pool = new ConnectionPool({ Connection }) const url = 'http://localhost:9200' - t.deepEqual( + t.same( pool.urlToHost(url), { url: new URL(url) } ) @@ -338,7 +338,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: { @@ -358,8 +358,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, '127.0.0.1:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, '127.0.0.1:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, '127.0.0.1:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, '127.0.0.1:9201') t.end() }) @@ -380,7 +380,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://[::1]:9200'), id: 'a1', roles: { @@ -400,8 +400,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, '[::1]:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, '[::1]:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, '[::1]:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, '[::1]:9201') t.end() }) @@ -422,7 +422,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://example.com:9200'), id: 'a1', roles: { @@ -442,8 +442,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') t.end() }) @@ -464,7 +464,7 @@ test('API', t => { } } - t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{ + t.same(pool.nodesToHost(nodes, 'http:'), [{ url: new URL('http://example.com:9200'), id: 'a1', roles: { @@ -484,8 +484,8 @@ test('API', t => { } }]) - t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') + t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201') t.end() }) @@ -506,8 +506,8 @@ test('API', t => { } } - t.strictEqual(pool.nodesToHost(nodes, 'https:')[0].url.protocol, 'https:') - t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.protocol, 'http:') + t.equal(pool.nodesToHost(nodes, 'https:')[0].url.protocol, 'https:') + t.equal(pool.nodesToHost(nodes, 'http:')[1].url.protocol, 'http:') t.end() }) @@ -662,13 +662,13 @@ test('API', t => { // roles will never be updated, we only use it to do // a dummy check to see if the connection has been updated - t.deepEqual(pool.connections.find(c => c.id === 'a1').roles, { + t.same(pool.connections.find(c => c.id === 'a1').roles, { master: true, data: true, ingest: true, ml: false }) - t.strictEqual(pool.connections.find(c => c.id === 'http://127.0.0.1:9200/'), undefined) + t.equal(pool.connections.find(c => c.id === 'http://127.0.0.1:9200/'), undefined) }) t.test('Add a new connection', t => { @@ -717,9 +717,9 @@ test('API', t => { roles: null }]) - t.false(pool.connections.find(c => c.id === 'a1')) - t.true(pool.connections.find(c => c.id === 'a2')) - t.true(pool.connections.find(c => c.id === 'a3')) + t.notOk(pool.connections.find(c => c.id === 'a1')) + t.ok(pool.connections.find(c => c.id === 'a2')) + t.ok(pool.connections.find(c => c.id === 'a3')) }) t.test('Remove old connections (markDead)', t => { @@ -732,7 +732,7 @@ test('API', t => { }) pool.markDead(conn) - t.deepEqual(pool.dead, ['a1']) + t.same(pool.dead, ['a1']) pool.update([{ url: new URL('http://127.0.0.1:9200'), @@ -744,10 +744,10 @@ test('API', t => { roles: null }]) - t.deepEqual(pool.dead, []) - t.false(pool.connections.find(c => c.id === 'a1')) - t.true(pool.connections.find(c => c.id === 'a2')) - t.true(pool.connections.find(c => c.id === 'a3')) + t.same(pool.dead, []) + t.notOk(pool.connections.find(c => c.id === 'a1')) + t.ok(pool.connections.find(c => c.id === 'a2')) + t.ok(pool.connections.find(c => c.id === 'a3')) }) t.end() @@ -761,14 +761,14 @@ test('Node selector', t => { t.plan(1) const pool = new ConnectionPool({ Connection }) pool.addConnection('http://localhost:9200/') - t.true(pool.getConnection({ selector: roundRobinSelector() }) instanceof Connection) + t.ok(pool.getConnection({ selector: roundRobinSelector() }) instanceof Connection) }) t.test('random', t => { t.plan(1) const pool = new ConnectionPool({ Connection }) pool.addConnection('http://localhost:9200/') - t.true(pool.getConnection({ selector: roundRobinSelector() }) instanceof Connection) + t.ok(pool.getConnection({ selector: roundRobinSelector() }) instanceof Connection) }) t.end() @@ -779,7 +779,7 @@ test('Node filter', t => { t.plan(1) const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL('http://localhost:9200/') }) - t.true(pool.getConnection({ filter: defaultNodeFilter }) instanceof Connection) + t.ok(pool.getConnection({ filter: defaultNodeFilter }) instanceof Connection) }) t.test('Should filter master only nodes', t => { @@ -794,7 +794,7 @@ test('Node filter', t => { ml: false } }) - t.strictEqual(pool.getConnection({ filter: defaultNodeFilter }), null) + t.equal(pool.getConnection({ filter: defaultNodeFilter }), null) }) t.end() diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 6b1b2e653..a951a9e6b 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -63,7 +63,7 @@ test('Basic (http)', t => { res.on('data', chunk => { payload += chunk }) res.on('error', err => t.fail(err)) res.on('end', () => { - t.strictEqual(payload, 'ok') + t.equal(payload, 'ok') server.stop() }) }) @@ -103,7 +103,7 @@ test('Basic (https)', t => { res.on('data', chunk => { payload += chunk }) res.on('error', err => t.fail(err)) res.on('end', () => { - t.strictEqual(payload, 'ok') + t.equal(payload, 'ok') server.stop() }) }) @@ -144,7 +144,7 @@ test('Basic (https with ssl agent)', t => { res.on('data', chunk => { payload += chunk }) res.on('error', err => t.fail(err)) res.on('end', () => { - t.strictEqual(payload, 'ok') + t.equal(payload, 'ok') server.stop() }) }) @@ -179,7 +179,7 @@ test('Custom http agent', t => { return agent } }) - t.true(connection.agent.custom) + t.ok(connection.agent.custom) connection.request({ path: '/hello', method: 'GET', @@ -198,7 +198,7 @@ test('Custom http agent', t => { res.on('data', chunk => { payload += chunk }) res.on('error', err => t.fail(err)) res.on('end', () => { - t.strictEqual(payload, 'ok') + t.equal(payload, 'ok') server.stop() }) }) @@ -268,7 +268,7 @@ test('querystring', t => { t.plan(2) function handler (req, res) { - t.strictEqual(req.url, '/hello?hello=world&you_know=for%20search') + t.equal(req.url, '/hello?hello=world&you_know=for%20search') res.end('ok') } @@ -291,7 +291,7 @@ test('querystring', t => { t.plan(2) function handler (req, res) { - t.strictEqual(req.url, '/hello') + t.equal(req.url, '/hello') res.end('ok') } @@ -322,7 +322,7 @@ test('Body request', t => { req.on('data', chunk => { payload += chunk }) req.on('error', err => t.fail(err)) req.on('end', () => { - t.strictEqual(payload, 'hello') + t.equal(payload, 'hello') res.end('ok') }) } @@ -351,7 +351,7 @@ test('Send body as buffer', t => { req.on('data', chunk => { payload += chunk }) req.on('error', err => t.fail(err)) req.on('end', () => { - t.strictEqual(payload, 'hello') + t.equal(payload, 'hello') res.end('ok') }) } @@ -380,7 +380,7 @@ test('Send body as stream', t => { req.on('data', chunk => { payload += chunk }) req.on('error', err => t.fail(err)) req.on('end', () => { - t.strictEqual(payload, 'hello') + t.equal(payload, 'hello') res.end('ok') }) } @@ -413,7 +413,7 @@ test('Should not close a connection if there are open requests', t => { }) setTimeout(() => { - t.strictEqual(connection._openRequests, 1) + t.equal(connection._openRequests, 1) connection.close() }, 500) @@ -422,14 +422,14 @@ test('Should not close a connection if there are open requests', t => { method: 'GET' }, (err, res) => { t.error(err) - t.strictEqual(connection._openRequests, 0) + t.equal(connection._openRequests, 0) let payload = '' res.setEncoding('utf8') res.on('data', chunk => { payload += chunk }) res.on('error', err => t.fail(err)) res.on('end', () => { - t.strictEqual(payload, 'ok') + t.equal(payload, 'ok') server.stop() }) }) @@ -450,7 +450,7 @@ test('Should not close a connection if there are open requests (with agent disab }) setTimeout(() => { - t.strictEqual(connection._openRequests, 1) + t.equal(connection._openRequests, 1) connection.close() }, 500) @@ -459,14 +459,14 @@ test('Should not close a connection if there are open requests (with agent disab method: 'GET' }, (err, res) => { t.error(err) - t.strictEqual(connection._openRequests, 0) + t.equal(connection._openRequests, 0) let payload = '' res.setEncoding('utf8') res.on('data', chunk => { payload += chunk }) res.on('error', err => t.fail(err)) res.on('end', () => { - t.strictEqual(payload, 'ok') + t.equal(payload, 'ok') server.stop() }) }) @@ -502,7 +502,7 @@ test('Url with querystring', t => { t.plan(2) function handler (req, res) { - t.strictEqual(req.url, '/hello?foo=bar&baz=faz') + t.equal(req.url, '/hello?foo=bar&baz=faz') res.end('ok') } @@ -546,7 +546,7 @@ test('Custom headers for connection', t => { }, (err, res) => { t.error(err) // should not update the default - t.deepEqual(connection.headers, { 'x-foo': 'bar' }) + t.same(connection.headers, { 'x-foo': 'bar' }) server.stop() }) }) @@ -576,7 +576,7 @@ test('asStream set to true', t => { res.on('data', chunk => { payload += chunk }) res.on('error', err => t.fail(err)) res.on('end', () => { - t.strictEqual(payload, 'ok') + t.equal(payload, 'ok') server.stop() }) }) @@ -587,7 +587,7 @@ test('Connection id should not contain credentials', t => { const connection = new Connection({ url: new URL('http://user:password@localhost:9200') }) - t.strictEqual(connection.id, 'http://localhost:9200/') + t.equal(connection.id, 'http://localhost:9200/') t.end() }) @@ -595,7 +595,7 @@ test('Ipv6 support', t => { const connection = new Connection({ url: new URL('http://[::1]:9200') }) - t.strictEqual(connection.buildRequestObject({}).hostname, '::1') + t.equal(connection.buildRequestObject({}).hostname, '::1') t.end() }) @@ -607,7 +607,7 @@ test('Should throw if the protocol is not http or https', t => { t.fail('Should throw') } catch (err) { t.ok(err instanceof ConfigurationError) - t.is(err.message, 'Invalid protocol: \'nope:\'') + t.equal(err.message, 'Invalid protocol: \'nope:\'') } t.end() }) @@ -623,7 +623,7 @@ test('Should disallow two-byte characters in URL path', t => { path: '/thisisinvalid\uffe2', method: 'GET' }, (err, res) => { - t.strictEqual( + t.equal( err.message, 'ERR_UNESCAPED_CHARACTERS: /thisisinvalid\uffe2' ) @@ -638,7 +638,7 @@ test('setRole', t => { url: new URL('http://localhost:9200') }) - t.deepEqual(connection.roles, { + t.same(connection.roles, { master: true, data: true, ingest: true, @@ -647,7 +647,7 @@ test('setRole', t => { connection.setRole('master', false) - t.deepEqual(connection.roles, { + t.same(connection.roles, { master: false, data: true, ingest: true, @@ -666,8 +666,8 @@ test('setRole', t => { connection.setRole('car', true) t.fail('Shoud throw') } catch (err) { - t.true(err instanceof ConfigurationError) - t.is(err.message, 'Unsupported role: \'car\'') + t.ok(err instanceof ConfigurationError) + t.equal(err.message, 'Unsupported role: \'car\'') } }) @@ -682,8 +682,8 @@ test('setRole', t => { connection.setRole('master', 1) t.fail('Shoud throw') } catch (err) { - t.true(err instanceof ConfigurationError) - t.is(err.message, 'enabled should be a boolean') + t.ok(err instanceof ConfigurationError) + t.equal(err.message, 'enabled should be a boolean') } }) @@ -708,7 +708,7 @@ test('Util.inspect Connection class should hide agent, ssl and auth', t => { .replace(/(\r\n|\n|\r)/gm, '') } - t.strictEqual(cleanStr(inspect(connection)), cleanStr(`{ url: 'http://localhost:9200/', + t.equal(cleanStr(inspect(connection)), cleanStr(`{ url: 'http://localhost:9200/', id: 'node-id', headers: { foo: 'bar' }, deadCount: 0, @@ -728,7 +728,7 @@ test('connection.toJSON should hide agent, ssl and auth', t => { headers: { foo: 'bar' } }) - t.deepEqual(connection.toJSON(), { + t.same(connection.toJSON(), { url: 'http://localhost:9200/', id: 'node-id', headers: { @@ -754,7 +754,7 @@ test('Port handling', t => { url: new URL('http://localhost:80') }) - t.strictEqual( + t.equal( connection.buildRequestObject({}).port, undefined ) @@ -767,7 +767,7 @@ test('Port handling', t => { url: new URL('https://localhost:443') }) - t.strictEqual( + t.equal( connection.buildRequestObject({}).port, undefined ) @@ -784,7 +784,7 @@ test('Authorization header', t => { url: new URL('http://localhost:9200') }) - t.deepEqual(connection.headers, {}) + t.same(connection.headers, {}) t.end() }) @@ -795,7 +795,7 @@ test('Authorization header', t => { auth: { username: 'foo', password: 'bar' } }) - t.deepEqual(connection.headers, { authorization: 'Basic Zm9vOmJhcg==' }) + t.same(connection.headers, { authorization: 'Basic Zm9vOmJhcg==' }) t.end() }) @@ -806,7 +806,7 @@ test('Authorization header', t => { auth: { apiKey: 'Zm9vOmJhcg==' } }) - t.deepEqual(connection.headers, { authorization: 'ApiKey Zm9vOmJhcg==' }) + t.same(connection.headers, { authorization: 'ApiKey Zm9vOmJhcg==' }) t.end() }) @@ -817,7 +817,7 @@ test('Authorization header', t => { auth: { apiKey: { id: 'foo', api_key: 'bar' } } }) - t.deepEqual(connection.headers, { authorization: 'ApiKey Zm9vOmJhcg==' }) + t.same(connection.headers, { authorization: 'ApiKey Zm9vOmJhcg==' }) t.end() }) @@ -830,7 +830,7 @@ test('Should not add agent and ssl to the serialized connection', t => { url: new URL('http://localhost:9200') }) - t.strictEqual( + t.equal( JSON.stringify(connection), '{"url":"http://localhost:9200/","id":"http://localhost:9200/","headers":{},"deadCount":0,"resurrectTimeout":0,"_openRequests":0,"status":"alive","roles":{"master":true,"data":true,"ingest":true,"ml":false}}' ) @@ -890,7 +890,7 @@ test('Should correctly resolve request pathname', t => { url: new URL('http://localhost:80/test') }) - t.strictEqual( + t.equal( connection.buildRequestObject({ path: 'hello' }).pathname, @@ -906,7 +906,7 @@ test('Proxy agent (http)', t => { proxy: 'http://localhost:8080' }) - t.true(connection.agent instanceof hpagent.HttpProxyAgent) + t.ok(connection.agent instanceof hpagent.HttpProxyAgent) }) test('Proxy agent (https)', t => { @@ -917,7 +917,7 @@ test('Proxy agent (https)', t => { proxy: 'http://localhost:8080' }) - t.true(connection.agent instanceof hpagent.HttpsProxyAgent) + t.ok(connection.agent instanceof hpagent.HttpsProxyAgent) }) test('Abort with a slow body', t => { diff --git a/test/unit/errors.test.js b/test/unit/errors.test.js index 783f1b2f6..301ca1108 100644 --- a/test/unit/errors.test.js +++ b/test/unit/errors.test.js @@ -26,57 +26,57 @@ const { errors } = require('../../index') test('ElasticsearchClientError', t => { const err = new errors.ElasticsearchClientError() - t.true(err instanceof Error) + t.ok(err instanceof Error) t.end() }) test('TimeoutError', t => { const err = new errors.TimeoutError() - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.true(err.hasOwnProperty('meta')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.ok(err.hasOwnProperty('meta')) t.end() }) test('ConnectionError', t => { const err = new errors.ConnectionError() - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.true(err.hasOwnProperty('meta')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.ok(err.hasOwnProperty('meta')) t.end() }) test('NoLivingConnectionsError', t => { const err = new errors.NoLivingConnectionsError() - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.true(err.hasOwnProperty('meta')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.ok(err.hasOwnProperty('meta')) t.end() }) test('SerializationError', t => { const err = new errors.SerializationError() - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.false(err.hasOwnProperty('meta')) - t.true(err.hasOwnProperty('data')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.notOk(err.hasOwnProperty('meta')) + t.ok(err.hasOwnProperty('data')) t.end() }) test('DeserializationError', t => { const err = new errors.DeserializationError() - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.false(err.hasOwnProperty('meta')) - t.true(err.hasOwnProperty('data')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.notOk(err.hasOwnProperty('meta')) + t.ok(err.hasOwnProperty('data')) t.end() }) test('ConfigurationError', t => { const err = new errors.ConfigurationError() - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.false(err.hasOwnProperty('meta')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.notOk(err.hasOwnProperty('meta')) t.end() }) @@ -87,9 +87,9 @@ test('ResponseError', t => { headers: 1 } const err = new errors.ResponseError(meta) - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.true(err.hasOwnProperty('meta')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.ok(err.hasOwnProperty('meta')) t.ok(err.body) t.ok(err.statusCode) t.ok(err.headers) @@ -98,9 +98,9 @@ test('ResponseError', t => { test('RequestAbortedError', t => { const err = new errors.RequestAbortedError() - t.true(err instanceof Error) - t.true(err instanceof errors.ElasticsearchClientError) - t.true(err.hasOwnProperty('meta')) + t.ok(err instanceof Error) + t.ok(err instanceof errors.ElasticsearchClientError) + t.ok(err.hasOwnProperty('meta')) t.end() }) @@ -131,8 +131,8 @@ test('ResponseError with meaningful message / 1', t => { headers: {} } const err = new errors.ResponseError(meta) - t.strictEqual(err.message, 'index_not_found_exception: [index_not_found_exception] Reason: no such index [foo]') - t.strictEqual(err.toString(), JSON.stringify(meta.body)) + t.equal(err.message, 'index_not_found_exception: [index_not_found_exception] Reason: no such index [foo]') + t.equal(err.toString(), JSON.stringify(meta.body)) t.end() }) @@ -171,8 +171,8 @@ test('ResponseError with meaningful message / 2', t => { headers: {} } const err = new errors.ResponseError(meta) - t.strictEqual(err.message, 'index_not_found_exception: [index_not_found_exception] Reason: no such index [foo]; [nested_cause] Reason: this is a nested cause') - t.strictEqual(err.toString(), JSON.stringify(meta.body)) + t.equal(err.message, 'index_not_found_exception: [index_not_found_exception] Reason: no such index [foo]; [nested_cause] Reason: this is a nested cause') + t.equal(err.toString(), JSON.stringify(meta.body)) t.end() }) @@ -193,7 +193,7 @@ test('ResponseError with meaningful message / 3', t => { headers: {} } const err = new errors.ResponseError(meta) - t.strictEqual(err.message, 'index_not_found_exception') - t.strictEqual(err.toString(), JSON.stringify(meta.body)) + t.equal(err.message, 'index_not_found_exception') + t.equal(err.toString(), JSON.stringify(meta.body)) t.end() }) diff --git a/test/unit/esm/index.mjs b/test/unit/esm/index.mjs index d78462891..4f5d17f6a 100644 --- a/test/unit/esm/index.mjs +++ b/test/unit/esm/index.mjs @@ -4,5 +4,5 @@ import { Client } from '../../../index.mjs' t.test('esm support', t => { t.plan(1) const client = new Client({ node: 'http://localhost:9200' }) - t.strictEqual(client.name, 'elasticsearch-js') + t.equal(client.name, 'elasticsearch-js') }) diff --git a/test/unit/events.test.js b/test/unit/events.test.js index cfaf20e29..6612213ca 100644 --- a/test/unit/events.test.js +++ b/test/unit/events.test.js @@ -289,7 +289,7 @@ test('Emit event', t => { client.on(events.REQUEST, (err, request) => { t.error(err) - t.deepEqual(request, { hello: 'world' }) + t.same(request, { hello: 'world' }) }) client.emit(events.REQUEST, null, { hello: 'world' }) diff --git a/test/unit/helpers/bulk.test.js b/test/unit/helpers/bulk.test.js index e99f3fba3..a2059fb73 100644 --- a/test/unit/helpers/bulk.test.js +++ b/test/unit/helpers/bulk.test.js @@ -44,14 +44,14 @@ test('bulk index', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson', 'x-elastic-client-meta': `es=${clientVersion},js=${nodeVersion},t=${clientVersion},hc=${nodeVersion},h=bp` }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test' } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test' } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) @@ -89,14 +89,14 @@ test('bulk index', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) t.notMatch(params.headers, { 'x-elastic-client-meta': `es=${clientVersion},js=${nodeVersion},t=${clientVersion},hc=${nodeVersion},h=bp` }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test' } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test' } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) @@ -134,9 +134,9 @@ test('bulk index', t => { t.test('Should perform a bulk request (high flush size)', async t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) - t.strictEqual(params.body.split('\n').filter(Boolean).length, 6) + t.equal(params.body.split('\n').filter(Boolean).length, 6) return { body: { errors: false, items: new Array(3).fill({}) } } } }) @@ -175,14 +175,14 @@ test('bulk index', t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { if (params.method === 'GET') { - t.strictEqual(params.path, '/_all/_refresh') + t.equal(params.path, '/_all/_refresh') return { body: { acknowledged: true } } } else { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test' } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test' } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } } @@ -220,14 +220,14 @@ test('bulk index', t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { if (params.method === 'GET') { - t.strictEqual(params.path, '/test/_refresh') + t.equal(params.path, '/test/_refresh') return { body: { acknowledged: true } } } else { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test' } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test' } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } } @@ -264,11 +264,11 @@ test('bulk index', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test', _id: count } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test', _id: count } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) @@ -308,7 +308,7 @@ test('bulk index', t => { t.test('Should perform a bulk request (retry)', async t => { async function handler (req, res) { - t.strictEqual(req.url, '/_bulk') + t.equal(req.url, '/_bulk') t.match(req.headers, { 'content-type': 'application/x-ndjson' }) let body = '' @@ -353,7 +353,7 @@ test('bulk index', t => { } }, onDrop (doc) { - t.deepEqual(doc, { + t.same(doc, { status: 429, error: null, operation: { index: { _index: 'test' } }, @@ -402,7 +402,7 @@ test('bulk index', t => { } }, onDrop (doc) { - t.deepEqual(doc, { + t.same(doc, { status: 429, error: null, operation: { index: { _index: 'test' } }, @@ -426,7 +426,7 @@ test('bulk index', t => { t.test('Should perform a bulk request (failure)', async t => { async function handler (req, res) { - t.strictEqual(req.url, '/_bulk') + t.equal(req.url, '/_bulk') t.match(req.headers, { 'content-type': 'application/x-ndjson' }) let body = '' @@ -471,7 +471,7 @@ test('bulk index', t => { } }, onDrop (doc) { - t.deepEqual(doc, { + t.same(doc, { status: 400, error: { something: 'went wrong' }, operation: { index: { _index: 'test' } }, @@ -525,7 +525,7 @@ test('bulk index', t => { await b t.fail('Should throw') } catch (err) { - t.true(err instanceof errors.ResponseError) + t.ok(err instanceof errors.ResponseError) } }) @@ -561,13 +561,13 @@ test('bulk index', t => { await b t.fail('Should throw') } catch (err) { - t.true(err instanceof errors.ResponseError) + t.ok(err instanceof errors.ResponseError) } }) t.test('Should abort a bulk request', async t => { async function handler (req, res) { - t.strictEqual(req.url, '/_bulk') + t.equal(req.url, '/_bulk') t.match(req.headers, { 'content-type': 'application/x-ndjson' }) let body = '' @@ -653,8 +653,8 @@ test('bulk index', t => { } }) .catch(err => { - t.true(err instanceof errors.ConfigurationError) - t.is(err.message, 'Bulk helper invalid action: \'foo\'') + t.ok(err instanceof errors.ConfigurationError) + t.equal(err.message, 'Bulk helper invalid action: \'foo\'') }) }) @@ -666,11 +666,11 @@ test('bulk index', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test', _id: count } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test', _id: count } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) @@ -718,11 +718,11 @@ test('bulk index', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test' } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test' } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) @@ -774,11 +774,11 @@ test('bulk create', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { create: { _index: 'test', _id: count } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { create: { _index: 'test', _id: count } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) @@ -823,11 +823,11 @@ test('bulk update', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { update: { _index: 'test', _id: count } }) - t.deepEqual(JSON.parse(payload), { doc: dataset[count++], doc_as_upsert: true }) + t.same(JSON.parse(action), { update: { _index: 'test', _id: count } }) + t.same(JSON.parse(payload), { doc: dataset[count++], doc_as_upsert: true }) return { body: { errors: false, items: [{}] } } } }) @@ -871,11 +871,11 @@ test('bulk update', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { update: { _index: 'test', _id: count } }) - t.deepEqual(JSON.parse(payload), { doc: dataset[count++] }) + t.same(JSON.parse(action), { update: { _index: 'test', _id: count } }) + t.same(JSON.parse(payload), { doc: dataset[count++] }) return { body: { errors: false, items: [{}] } } } }) @@ -921,9 +921,9 @@ test('bulk delete', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) - t.deepEqual(JSON.parse(params.body), { delete: { _index: 'test', _id: count++ } }) + t.same(JSON.parse(params.body), { delete: { _index: 'test', _id: count++ } }) return { body: { errors: false, items: [{}] } } } }) @@ -963,7 +963,7 @@ test('bulk delete', t => { t.test('Should perform a bulk request (failure)', async t => { async function handler (req, res) { - t.strictEqual(req.url, '/_bulk') + t.equal(req.url, '/_bulk') t.match(req.headers, { 'content-type': 'application/x-ndjson' }) let body = '' @@ -1011,7 +1011,7 @@ test('bulk delete', t => { } }, onDrop (doc) { - t.deepEqual(doc, { + t.same(doc, { status: 400, error: { something: 'went wrong' }, operation: { delete: { _index: 'test', _id: 1 } }, @@ -1051,7 +1051,7 @@ test('transport options', t => { return { body: { errors: false, items: [{}] } } } - t.strictEqual(params.path, '/_all/_refresh') + t.equal(params.path, '/_all/_refresh') t.match(params.headers, { foo: 'bar' }) @@ -1081,7 +1081,7 @@ test('transport options', t => { } }) - t.strictEqual(count, 4) // three bulk requests, one refresh + t.equal(count, 4) // three bulk requests, one refresh t.type(result.time, 'number') t.type(result.bytes, 'number') t.match(result, { @@ -1111,8 +1111,8 @@ test('errors', t => { } }) } catch (err) { - t.true(err instanceof errors.ConfigurationError) - t.is(err.message, 'bulk helper: the datasource must be an array or a buffer or a readable stream or an async generator') + t.ok(err instanceof errors.ConfigurationError) + t.equal(err.message, 'bulk helper: the datasource must be an array or a buffer or a readable stream or an async generator') } }) @@ -1129,8 +1129,8 @@ test('errors', t => { } }) } catch (err) { - t.true(err instanceof errors.ConfigurationError) - t.is(err.message, 'bulk helper: the datasource is required') + t.ok(err instanceof errors.ConfigurationError) + t.equal(err.message, 'bulk helper: the datasource is required') } }) @@ -1143,8 +1143,8 @@ test('errors', t => { datasource: dataset.slice() }) } catch (err) { - t.true(err instanceof errors.ConfigurationError) - t.is(err.message, 'bulk helper: the onDocument callback is required') + t.ok(err instanceof errors.ConfigurationError) + t.equal(err.message, 'bulk helper: the onDocument callback is required') } }) @@ -1159,11 +1159,11 @@ test('Flush interval', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.path, '/_bulk') + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test' } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test' } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) @@ -1210,12 +1210,12 @@ test('Flush interval', t => { let count = 0 const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.true(count < 2) - t.strictEqual(params.path, '/_bulk') + t.ok(count < 2) + t.equal(params.path, '/_bulk') t.match(params.headers, { 'content-type': 'application/x-ndjson' }) const [action, payload] = params.body.split('\n') - t.deepEqual(JSON.parse(action), { index: { _index: 'test' } }) - t.deepEqual(JSON.parse(payload), dataset[count++]) + t.same(JSON.parse(action), { index: { _index: 'test' } }) + t.same(JSON.parse(payload), dataset[count++]) return { body: { errors: false, items: [{}] } } } }) diff --git a/test/unit/helpers/msearch.test.js b/test/unit/helpers/msearch.test.js index b3edf3756..b80792fa5 100644 --- a/test/unit/helpers/msearch.test.js +++ b/test/unit/helpers/msearch.test.js @@ -56,7 +56,7 @@ test('Basic', async t => { { query: { match: { foo: 'bar' } } } ) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -67,7 +67,7 @@ test('Basic', async t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -116,7 +116,7 @@ test('Multiple searches (inside async iterator)', t => { m.search({ index: 'test' }, { query: { match: { foo: 'bar' } } }, (err, result) => { t.error(err) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -127,7 +127,7 @@ test('Multiple searches (inside async iterator)', t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -136,7 +136,7 @@ test('Multiple searches (inside async iterator)', t => { m.search({ index: 'test' }, { query: { match: { foo: 'bar' } } }, (err, result) => { t.error(err) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -147,7 +147,7 @@ test('Multiple searches (inside async iterator)', t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { four: 'four' }, { five: 'five' }, { six: 'six' } @@ -197,7 +197,7 @@ test('Multiple searches (async iterator exits)', t => { m.search({ index: 'test' }, { query: {} }, (err, result) => { t.error(err) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -208,7 +208,7 @@ test('Multiple searches (async iterator exits)', t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -217,7 +217,7 @@ test('Multiple searches (async iterator exits)', t => { m.search({ index: 'test' }, { query: { match: { foo: 'bar' } } }, (err, result) => { t.error(err) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -228,7 +228,7 @@ test('Multiple searches (async iterator exits)', t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { four: 'four' }, { five: 'five' }, { six: 'six' } @@ -260,7 +260,7 @@ test('Stop a msearch processor (promises)', async t => { { query: { match: { foo: 'bar' } } } ) } catch (err) { - t.strictEqual(err.message, 'The msearch processor has been stopped') + t.equal(err.message, 'The msearch processor has been stopped') } t.teardown(() => m.stop()) @@ -285,7 +285,7 @@ test('Stop a msearch processor (callbacks)', t => { m.stop() m.search({ index: 'test' }, { query: { match: { foo: 'bar' } } }, (err, result) => { - t.strictEqual(err.message, 'The msearch processor has been stopped') + t.equal(err.message, 'The msearch processor has been stopped') }) }) @@ -306,12 +306,12 @@ test('Bad header', t => { const m = client.helpers.msearch() m.search(null, { query: { match: { foo: 'bar' } } }, (err, result) => { - t.strictEqual(err.message, 'The header should be an object') + t.equal(err.message, 'The header should be an object') }) m.search(null, { query: { match: { foo: 'bar' } } }) .catch(err => { - t.strictEqual(err.message, 'The header should be an object') + t.equal(err.message, 'The header should be an object') }) t.teardown(() => m.stop()) @@ -334,12 +334,12 @@ test('Bad body', t => { const m = client.helpers.msearch() m.search({ index: 'test' }, null, (err, result) => { - t.strictEqual(err.message, 'The body should be an object') + t.equal(err.message, 'The body should be an object') }) m.search({ index: 'test' }, null) .catch(err => { - t.strictEqual(err.message, 'The body should be an object') + t.equal(err.message, 'The body should be an object') }) t.teardown(() => m.stop()) @@ -389,7 +389,7 @@ test('Retry on 429', async t => { { query: { match: { foo: 'bar' } } } ) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -400,7 +400,7 @@ test('Retry on 429', async t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -436,7 +436,7 @@ test('Single search errors', async t => { { query: { match: { foo: 'bar' } } } ) } catch (err) { - t.true(err instanceof errors.ResponseError) + t.ok(err instanceof errors.ResponseError) } t.teardown(() => m.stop()) @@ -465,13 +465,13 @@ test('Entire msearch fails', t => { const m = client.helpers.msearch({ operations: 1 }) m.search({ index: 'test' }, { query: {} }, (err, result) => { - t.true(err instanceof errors.ResponseError) - t.deepEqual(result.documents, []) + t.ok(err instanceof errors.ResponseError) + t.same(result.documents, []) }) m.search({ index: 'test' }, { query: {} }, (err, result) => { - t.true(err instanceof errors.ResponseError) - t.deepEqual(result.documents, []) + t.ok(err instanceof errors.ResponseError) + t.same(result.documents, []) }) t.teardown(() => m.stop()) @@ -523,13 +523,13 @@ test('Stop the msearch helper with an error', t => { m.then( () => t.fail('Should fail'), - err => t.is(err.message, 'kaboom') + err => t.equal(err.message, 'kaboom') ) - m.catch(err => t.is(err.message, 'kaboom')) + m.catch(err => t.equal(err.message, 'kaboom')) m.search({ index: 'test' }, { query: {} }, (err, result) => { - t.is(err.message, 'kaboom') + t.equal(err.message, 'kaboom') }) }) @@ -564,7 +564,7 @@ test('Multiple searches (concurrency = 1)', t => { m.search({ index: 'test' }, { query: {} }, (err, result) => { t.error(err) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -575,7 +575,7 @@ test('Multiple searches (concurrency = 1)', t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -584,7 +584,7 @@ test('Multiple searches (concurrency = 1)', t => { m.search({ index: 'test' }, { query: {} }, (err, result) => { t.error(err) - t.deepEqual(result.body, { + t.same(result.body, { status: 200, hits: { hits: [ @@ -595,7 +595,7 @@ test('Multiple searches (concurrency = 1)', t => { } }) - t.deepEqual(result.documents, [ + t.same(result.documents, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -647,12 +647,12 @@ test('Flush interval', t => { m.search({ index: 'test' }, { query: { match: { foo: 'bar' } } }, (err, result) => { t.error(err) - t.is(result.documents.length, 3) + t.equal(result.documents.length, 3) }) m.search({ index: 'test' }, { query: { match: { foo: 'bar' } } }, (err, result) => { t.error(err) - t.is(result.documents.length, 3) + t.equal(result.documents.length, 3) }) setImmediate(clock.next) @@ -691,7 +691,7 @@ test('Flush interval - early stop', t => { m.search({ index: 'test' }, { query: { match: { foo: 'bar' } } }, (err, result) => { t.error(err) - t.is(result.documents.length, 3) + t.equal(result.documents.length, 3) }) setImmediate(() => { @@ -750,11 +750,11 @@ test('Stop should resolve the helper (error)', t => { setImmediate(m.stop, new Error('kaboom')) m.then(() => t.fail('Should not fail')) - .catch(err => t.is(err.message, 'kaboom')) + .catch(err => t.equal(err.message, 'kaboom')) - m.catch(err => t.is(err.message, 'kaboom')) + m.catch(err => t.equal(err.message, 'kaboom')) - m.then(() => t.fail('Should not fail'), err => t.is(err.message, 'kaboom')) + m.then(() => t.fail('Should not fail'), err => t.equal(err.message, 'kaboom')) }) test('Should use req options', async t => { diff --git a/test/unit/helpers/scroll.test.js b/test/unit/helpers/scroll.test.js index cfc26d959..4943e703b 100644 --- a/test/unit/helpers/scroll.test.js +++ b/test/unit/helpers/scroll.test.js @@ -38,11 +38,11 @@ test('Scroll search', async t => { count += 1 if (params.method === 'POST') { - t.strictEqual(params.querystring, 'scroll=1m') + t.equal(params.querystring, 'scroll=1m') } if (count === 4) { // final automated clear - t.strictEqual(params.method, 'DELETE') + t.equal(params.method, 'DELETE') } return { body: { @@ -73,8 +73,8 @@ test('Scroll search', async t => { }) for await (const result of scrollSearch) { - t.strictEqual(result.body.count, count) - t.strictEqual(result.body._scroll_id, 'id') + t.equal(result.body.count, count) + t.equal(result.body._scroll_id, 'id') } }) @@ -87,7 +87,7 @@ test('Clear a scroll search', async t => { }) if (params.method === 'DELETE') { const body = JSON.parse(params.body) - t.strictEqual(body.scroll_id, 'id') + t.equal(body.scroll_id, 'id') } return { body: { @@ -120,7 +120,7 @@ test('Clear a scroll search', async t => { if (count === 2) { t.fail('The scroll search should be cleared') } - t.strictEqual(result.body.count, count) + t.equal(result.body.count, count) if (count === 1) { await result.clear() } @@ -138,7 +138,7 @@ test('Scroll search (retry)', async t => { } if (count === 5) { // final automated clear - t.strictEqual(params.method, 'DELETE') + t.equal(params.method, 'DELETE') } return { statusCode: 200, @@ -172,9 +172,9 @@ test('Scroll search (retry)', async t => { }) for await (const result of scrollSearch) { - t.strictEqual(result.body.count, count) - t.notStrictEqual(result.body.count, 1) - t.strictEqual(result.body._scroll_id, 'id') + t.equal(result.body.count, count) + t.not(result.body.count, 1) + t.equal(result.body._scroll_id, 'id') } }) @@ -208,9 +208,9 @@ test('Scroll search (retry throws and maxRetries)', async t => { t.fail('we should not be here') } } catch (err) { - t.true(err instanceof errors.ResponseError) - t.strictEqual(err.statusCode, 429) - t.strictEqual(count, expectedAttempts) + t.ok(err instanceof errors.ResponseError) + t.equal(err.statusCode, 429) + t.equal(count, expectedAttempts) } }) @@ -222,7 +222,7 @@ test('Scroll search (retry throws later)', async t => { onRequest (params) { count += 1 // filter_path should not be added if is not already present - t.strictEqual(params.querystring, 'scroll=1m') + t.equal(params.querystring, 'scroll=1m') if (count > 1) { return { body: {}, statusCode: 429 } } @@ -258,12 +258,12 @@ test('Scroll search (retry throws later)', async t => { try { for await (const result of scrollSearch) { // eslint-disable-line - t.strictEqual(result.body.count, count) + t.equal(result.body.count, count) } } catch (err) { - t.true(err instanceof errors.ResponseError) - t.strictEqual(err.statusCode, 429) - t.strictEqual(count, expectedAttempts) + t.ok(err instanceof errors.ResponseError) + t.equal(err.statusCode, 429) + t.equal(count, expectedAttempts) } }) @@ -272,11 +272,11 @@ test('Scroll search documents', async t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { if (count === 0) { - t.strictEqual(params.querystring, 'filter_path=hits.hits._source%2C_scroll_id&scroll=1m') + t.equal(params.querystring, 'filter_path=hits.hits._source%2C_scroll_id&scroll=1m') } else { if (params.method !== 'DELETE') { - t.strictEqual(params.querystring, 'scroll=1m') - t.strictEqual(params.body, '{"scroll_id":"id"}') + t.equal(params.querystring, 'scroll=1m') + t.equal(params.body, '{"scroll_id":"id"}') } } return { @@ -309,7 +309,7 @@ test('Scroll search documents', async t => { let n = 1 for await (const hit of scrollSearch) { - t.deepEqual(hit, { val: n * count }) + t.same(hit, { val: n * count }) n += 1 if (n === 4) { count += 1 @@ -348,9 +348,9 @@ test('Should not retry if maxRetries = 0', async t => { t.fail('we should not be here') } } catch (err) { - t.true(err instanceof errors.ResponseError) - t.strictEqual(err.statusCode, 429) - t.strictEqual(count, expectedAttempts) + t.ok(err instanceof errors.ResponseError) + t.equal(err.statusCode, 429) + t.equal(count, expectedAttempts) } }) @@ -359,10 +359,10 @@ test('Fix querystring for scroll search', async t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { if (count === 0) { - t.strictEqual(params.querystring, 'size=1&scroll=1m') + t.equal(params.querystring, 'size=1&scroll=1m') } else { if (params.method !== 'DELETE') { - t.strictEqual(params.querystring, 'scroll=1m') + t.equal(params.querystring, 'scroll=1m') } } return { @@ -392,7 +392,7 @@ test('Fix querystring for scroll search', async t => { }) for await (const response of scrollSearch) { - t.strictEqual(response.body.hits.hits.length, 1) + t.equal(response.body.hits.hits.length, 1) count += 1 } }) diff --git a/test/unit/helpers/search.test.js b/test/unit/helpers/search.test.js index 06ce5870a..ad01ad35a 100644 --- a/test/unit/helpers/search.test.js +++ b/test/unit/helpers/search.test.js @@ -26,7 +26,7 @@ const { connection } = require('../../utils') test('Search should have an additional documents property', async t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.querystring, 'filter_path=hits.hits._source') + t.equal(params.querystring, 'filter_path=hits.hits._source') return { body: { hits: { @@ -50,7 +50,7 @@ test('Search should have an additional documents property', async t => { index: 'test', body: { foo: 'bar' } }) - t.deepEqual(result, [ + t.same(result, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -60,7 +60,7 @@ test('Search should have an additional documents property', async t => { test('kGetHits fallback', async t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.querystring, 'filter_path=hits.hits._source') + t.equal(params.querystring, 'filter_path=hits.hits._source') return { body: {} } } }) @@ -74,13 +74,13 @@ test('kGetHits fallback', async t => { index: 'test', body: { foo: 'bar' } }) - t.deepEqual(result, []) + t.same(result, []) }) test('Merge filter paths (snake_case)', async t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.querystring, 'filter_path=foo%2Chits.hits._source') + t.equal(params.querystring, 'filter_path=foo%2Chits.hits._source') return { body: { hits: { @@ -105,7 +105,7 @@ test('Merge filter paths (snake_case)', async t => { filter_path: 'foo', body: { foo: 'bar' } }) - t.deepEqual(result, [ + t.same(result, [ { one: 'one' }, { two: 'two' }, { three: 'three' } @@ -115,7 +115,7 @@ test('Merge filter paths (snake_case)', async t => { test('Merge filter paths (camelCase)', async t => { const MockConnection = connection.buildMockConnection({ onRequest (params) { - t.strictEqual(params.querystring, 'filter_path=foo%2Chits.hits._source') + t.equal(params.querystring, 'filter_path=foo%2Chits.hits._source') return { body: { hits: { @@ -140,7 +140,7 @@ test('Merge filter paths (camelCase)', async t => { filterPath: 'foo', body: { foo: 'bar' } }) - t.deepEqual(result, [ + t.same(result, [ { one: 'one' }, { two: 'two' }, { three: 'three' } diff --git a/test/unit/selectors.test.js b/test/unit/selectors.test.js index 798a457e0..54f3087c2 100644 --- a/test/unit/selectors.test.js +++ b/test/unit/selectors.test.js @@ -28,7 +28,7 @@ test('RoundRobinSelector', t => { t.plan(arr.length + 1) for (let i = 0; i <= arr.length; i++) { - t.strictEqual( + t.equal( selector(arr), i === arr.length ? arr[0] : arr[i] ) diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js index d0e847300..edf29c880 100644 --- a/test/unit/serializer.test.js +++ b/test/unit/serializer.test.js @@ -29,8 +29,8 @@ test('Basic', t => { const s = new Serializer() const obj = { hello: 'world' } const json = JSON.stringify(obj) - t.strictEqual(s.serialize(obj), json) - t.deepEqual(s.deserialize(json), obj) + t.equal(s.serialize(obj), json) + t.same(s.deserialize(json), obj) }) test('ndserialize', t => { @@ -41,7 +41,7 @@ test('ndserialize', t => { { winter: 'is coming' }, { you_know: 'for search' } ] - t.strictEqual( + t.equal( s.ndserialize(obj), JSON.stringify(obj[0]) + '\n' + JSON.stringify(obj[1]) + '\n' + @@ -57,7 +57,7 @@ test('ndserialize (strings)', t => { JSON.stringify({ winter: 'is coming' }), JSON.stringify({ you_know: 'for search' }) ] - t.strictEqual( + t.equal( s.ndserialize(obj), obj[0] + '\n' + obj[1] + '\n' + @@ -73,7 +73,7 @@ test('qserialize', t => { you_know: 'for search' } - t.strictEqual( + t.equal( s.qserialize(obj), stringify(obj) ) @@ -87,7 +87,7 @@ test('qserialize (array)', t => { arr: ['foo', 'bar'] } - t.strictEqual( + t.equal( s.qserialize(obj), 'hello=world&arr=foo%2Cbar' ) @@ -101,7 +101,7 @@ test('qserialize (string)', t => { you_know: 'for search' } - t.strictEqual( + t.equal( s.qserialize(stringify(obj)), stringify(obj) ) @@ -116,7 +116,7 @@ test('qserialize (key with undefined value)', t => { foo: 'bar' } - t.strictEqual( + t.equal( s.qserialize(obj), 'hello=world&foo=bar' ) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index dbb1f5df0..410fe8995 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -71,7 +71,7 @@ test('Basic', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -99,7 +99,7 @@ test('Basic (promises support)', t => { path: '/hello' }) .then(({ body }) => { - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) }) .catch(t.fail) }) @@ -154,7 +154,7 @@ test('Basic (options + promises support)', t => { requestTimeout: 1000 }) .then(({ body }) => { - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) }) .catch(t.fail) }) @@ -171,7 +171,7 @@ test('Send POST', t => { req.on('data', chunk => { json += chunk }) req.on('error', err => t.fail(err)) req.on('end', () => { - t.deepEqual(JSON.parse(json), { hello: 'world' }) + t.same(JSON.parse(json), { hello: 'world' }) res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) }) @@ -197,7 +197,7 @@ test('Send POST', t => { body: { hello: 'world' } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -222,7 +222,7 @@ test('Send POST (ndjson)', t => { req.on('data', chunk => { json += chunk }) req.on('error', err => t.fail(err)) req.on('end', () => { - t.strictEqual( + t.equal( json, JSON.stringify(bulkBody[0]) + '\n' + JSON.stringify(bulkBody[1]) + '\n' + @@ -253,7 +253,7 @@ test('Send POST (ndjson)', t => { bulkBody }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -270,7 +270,7 @@ test('Send stream', t => { req.on('data', chunk => { json += chunk }) req.on('error', err => t.fail(err)) req.on('end', () => { - t.deepEqual(JSON.parse(json), { hello: 'world' }) + t.same(JSON.parse(json), { hello: 'world' }) res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) }) @@ -296,7 +296,7 @@ test('Send stream', t => { body: intoStream(JSON.stringify({ hello: 'world' })) }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -313,7 +313,7 @@ test('Send stream (bulkBody)', t => { req.on('data', chunk => { json += chunk }) req.on('error', err => t.fail(err)) req.on('end', () => { - t.deepEqual(JSON.parse(json), { hello: 'world' }) + t.same(JSON.parse(json), { hello: 'world' }) res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) }) @@ -339,7 +339,7 @@ test('Send stream (bulkBody)', t => { bulkBody: intoStream(JSON.stringify({ hello: 'world' })) }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -371,7 +371,7 @@ test('Not JSON payload from server', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.strictEqual(body, 'hello!') + t.equal(body, 'hello!') server.stop() }) }) @@ -391,8 +391,8 @@ test('NoLivingConnectionsError (null connection)', t => { sniffInterval: false, sniffOnStart: false, nodeSelector (connections) { - t.is(connections.length, 1) - t.true(connections[0] instanceof Connection) + t.equal(connections.length, 1) + t.ok(connections[0] instanceof Connection) return null } }) @@ -419,8 +419,8 @@ test('NoLivingConnectionsError (undefined connection)', t => { sniffInterval: false, sniffOnStart: false, nodeSelector (connections) { - t.is(connections.length, 1) - t.true(connections[0] instanceof Connection) + t.equal(connections.length, 1) + t.ok(connections[0] instanceof Connection) return undefined } }) @@ -521,7 +521,7 @@ test('TimeoutError (should call markDead on the failing connection)', t => { class CustomConnectionPool extends ConnectionPool { markDead (connection) { - t.strictEqual(connection.id, 'node1') + t.equal(connection.id, 'node1') super.markDead(connection) } } @@ -555,7 +555,7 @@ test('ConnectionError (should call markDead on the failing connection)', t => { class CustomConnectionPool extends ConnectionPool { markDead (connection) { - t.strictEqual(connection.id, 'node1') + t.equal(connection.id, 'node1') super.markDead(connection) } } @@ -626,7 +626,7 @@ test('Retry mechanism', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -671,7 +671,7 @@ test('Should not retry if the body is a stream', t => { body: intoStream(JSON.stringify({ hello: 'world' })) }, (err, { body }) => { t.ok(err instanceof ResponseError) - t.strictEqual(count, 1) + t.equal(count, 1) server.stop() }) }) @@ -716,7 +716,7 @@ test('Should not retry if the bulkBody is a stream', t => { bulkBody: intoStream(JSON.stringify([{ hello: 'world' }])) }, (err, { body }) => { t.ok(err instanceof ResponseError) - t.strictEqual(count, 1) + t.equal(count, 1) server.stop() }) }) @@ -763,7 +763,7 @@ test('No retry', t => { maxRetries: 0 }, (err, { body }) => { t.ok(err instanceof ResponseError) - t.strictEqual(count, 1) + t.equal(count, 1) server.stop() }) }) @@ -813,7 +813,7 @@ test('Custom retry mechanism', t => { maxRetries: 1 }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -824,7 +824,7 @@ test('Should not retry on 429', t => { let count = 0 function handler (req, res) { - t.strictEqual(count++, 0) + t.equal(count++, 0) res.statusCode = 429 res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) @@ -858,7 +858,7 @@ test('Should not retry on 429', t => { path: '/hello' }, (err, result) => { t.ok(err) - t.strictEqual(err.statusCode, 429) + t.equal(err.statusCode, 429) server.stop() }) }) @@ -869,7 +869,7 @@ test('Should call markAlive with a successful response', t => { class CustomConnectionPool extends ConnectionPool { markAlive (connection) { - t.strictEqual(connection.id, 'node1') + t.equal(connection.id, 'node1') super.markAlive(connection) } } @@ -895,7 +895,7 @@ test('Should call markAlive with a successful response', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) }) }) @@ -932,7 +932,7 @@ test('Should call resurrect on every request', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) }) }) @@ -1076,8 +1076,8 @@ test('ResponseError', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof ResponseError) - t.deepEqual(err.body, { status: 500 }) - t.strictEqual(err.statusCode, 500) + t.same(err.body, { status: 500 }) + t.equal(err.statusCode, 500) server.stop() }) }) @@ -1113,7 +1113,7 @@ test('Override requestTimeout', t => { requestTimeout: 2000 }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1125,7 +1125,7 @@ test('sniff', t => { class MyTransport extends Transport { sniff (opts) { - t.strictEqual(opts.reason, Transport.sniffReasons.SNIFF_ON_START) + t.equal(opts.reason, Transport.sniffReasons.SNIFF_ON_START) } } @@ -1150,7 +1150,7 @@ test('sniff', t => { class MyTransport extends Transport { sniff (opts) { - t.strictEqual(opts.reason, Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) + t.equal(opts.reason, Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) } } @@ -1184,7 +1184,7 @@ test('sniff', t => { class MyTransport extends Transport { sniff (opts) { - t.strictEqual(opts.reason, Transport.sniffReasons.SNIFF_INTERVAL) + t.equal(opts.reason, Transport.sniffReasons.SNIFF_INTERVAL) } } @@ -1329,7 +1329,7 @@ test('Should retry the request if the statusCode is 502/3/4', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1362,7 +1362,7 @@ test('Ignore status code', t => { ignore: [404] }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) }) transport.request({ @@ -1386,7 +1386,7 @@ test('Should serialize the querystring', t => { t.plan(2) function handler (req, res) { - t.strictEqual(req.url, '/hello?hello=world&you_know=for%20search') + t.equal(req.url, '/hello?hello=world&you_know=for%20search') res.end('ok') } @@ -1582,8 +1582,8 @@ test('Should cast to boolean HEAD request', t => { path: '/200' }, (err, { body, statusCode }) => { t.error(err) - t.strictEqual(statusCode, 200) - t.strictEqual(body, true) + t.equal(statusCode, 200) + t.equal(body, true) }) }) @@ -1607,8 +1607,8 @@ test('Should cast to boolean HEAD request', t => { path: '/404' }, (err, { body, statusCode }) => { t.error(err) - t.strictEqual(statusCode, 404) - t.strictEqual(body, false) + t.equal(statusCode, 404) + t.equal(body, false) }) }) @@ -1633,8 +1633,8 @@ test('Should cast to boolean HEAD request', t => { path: '/400' }, (err, { body, statusCode }) => { t.ok(err instanceof ResponseError) - t.false(typeof err.body === 'boolean') - t.strictEqual(statusCode, 400) + t.notOk(typeof err.body === 'boolean') + t.equal(statusCode, 400) }) }) @@ -1658,8 +1658,8 @@ test('Should cast to boolean HEAD request', t => { path: '/500' }, (err, { body, statusCode }) => { t.ok(err instanceof ResponseError) - t.false(typeof err.body === 'boolean') - t.strictEqual(statusCode, 500) + t.notOk(typeof err.body === 'boolean') + t.equal(statusCode, 500) }) }) @@ -1700,7 +1700,7 @@ test('Suggest compression', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -1775,7 +1775,7 @@ test('Warning header', t => { path: '/hello' }, (err, { warnings }) => { t.error(err) - t.deepEqual(warnings, [warn]) + t.same(warnings, [warn]) warnings.forEach(w => t.type(w, 'string')) server.stop() }) @@ -1812,7 +1812,7 @@ test('Warning header', t => { path: '/hello' }, (err, { warnings }) => { t.error(err) - t.deepEqual(warnings, [warn1, warn2]) + t.same(warnings, [warn1, warn2]) warnings.forEach(w => t.type(w, 'string')) server.stop() }) @@ -1846,7 +1846,7 @@ test('Warning header', t => { path: '/hello' }, (err, { warnings }) => { t.error(err) - t.strictEqual(warnings, null) + t.equal(warnings, null) server.stop() }) }) @@ -1893,7 +1893,7 @@ test('asStream set to true', t => { body.on('data', chunk => { payload += chunk }) body.on('error', err => t.fail(err)) body.on('end', () => { - t.deepEqual(JSON.parse(payload), { hello: 'world' }) + t.same(JSON.parse(payload), { hello: 'world' }) server.stop() }) }) @@ -1914,7 +1914,7 @@ test('Compress request', t => { .on('data', chunk => { json += chunk }) .on('error', err => t.fail(err)) .on('end', () => { - t.deepEqual(JSON.parse(json), { you_know: 'for search' }) + t.same(JSON.parse(json), { you_know: 'for search' }) res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ you_know: 'for search' })) }) @@ -1942,7 +1942,7 @@ test('Compress request', t => { compression: 'gzip' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { you_know: 'for search' }) + t.same(body, { you_know: 'for search' }) server.stop() }) }) @@ -1961,7 +1961,7 @@ test('Compress request', t => { .on('data', chunk => { json += chunk }) .on('error', err => t.fail(err)) .on('end', () => { - t.deepEqual(JSON.parse(json), { you_know: 'for search' }) + t.same(JSON.parse(json), { you_know: 'for search' }) res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ you_know: 'for search' })) }) @@ -1988,7 +1988,7 @@ test('Compress request', t => { body: { you_know: 'for search' } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { you_know: 'for search' }) + t.same(body, { you_know: 'for search' }) server.stop() }) }) @@ -2007,7 +2007,7 @@ test('Compress request', t => { .on('data', chunk => { json += chunk }) .on('error', err => t.fail(err)) .on('end', () => { - t.deepEqual(JSON.parse(json), { you_know: 'for search' }) + t.same(JSON.parse(json), { you_know: 'for search' }) res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ you_know: 'for search' })) }) @@ -2035,7 +2035,7 @@ test('Compress request', t => { compression: 'gzip' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { you_know: 'for search' }) + t.same(body, { you_know: 'for search' }) server.stop() }) }) @@ -2057,8 +2057,8 @@ test('Compress request', t => { }) t.fail('Should throw') } catch (err) { - t.true(err instanceof ConfigurationError) - t.is(err.message, 'Invalid compression: \'deflate\'') + t.ok(err instanceof ConfigurationError) + t.equal(err.message, 'Invalid compression: \'deflate\'') } }) @@ -2066,8 +2066,8 @@ test('Compress request', t => { t.plan(9) function handler (req, res) { - t.strictEqual(req.headers['content-encoding'], undefined) - t.strictEqual(req.headers['content-type'], undefined) + t.equal(req.headers['content-encoding'], undefined) + t.equal(req.headers['content-type'], undefined) res.end() } @@ -2126,7 +2126,7 @@ test('Compress request', t => { .on('data', chunk => { json += chunk }) .on('error', err => t.fail(err)) .on('end', () => { - t.deepEqual(JSON.parse(json), { you_know: 'for search' }) + t.same(JSON.parse(json), { you_know: 'for search' }) res.setHeader('Content-Type', 'application/json;utf=8') if (count++ > 0) { res.end(JSON.stringify({ you_know: 'for search' })) @@ -2160,8 +2160,8 @@ test('Compress request', t => { compression: 'gzip' }, (err, { body, meta }) => { t.error(err) - t.deepEqual(body, { you_know: 'for search' }) - t.strictEqual(count, 2) + t.same(body, { you_know: 'for search' }) + t.equal(count, 2) server.stop() }) }) @@ -2201,7 +2201,7 @@ test('Headers configuration', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -2242,7 +2242,7 @@ test('Headers configuration', t => { headers: { 'x-baz': 'faz' } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -2280,7 +2280,7 @@ test('Headers configuration', t => { headers: { 'x-foo': 'faz' } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -2318,7 +2318,7 @@ test('nodeFilter and nodeSelector', t => { path: '/hello' }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) }) }) @@ -2327,7 +2327,7 @@ test('Should accept custom querystring in the optons object', t => { t.plan(3) function handler (req, res) { - t.strictEqual(req.url, '/hello?foo=bar') + t.equal(req.url, '/hello?foo=bar') res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } @@ -2353,7 +2353,7 @@ test('Should accept custom querystring in the optons object', t => { querystring: { foo: 'bar' } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -2363,7 +2363,7 @@ test('Should accept custom querystring in the optons object', t => { t.plan(3) function handler (req, res) { - t.strictEqual(req.url, '/hello?baz=faz&foo=bar') + t.equal(req.url, '/hello?baz=faz&foo=bar') res.setHeader('Content-Type', 'application/json;utf=8') res.end(JSON.stringify({ hello: 'world' })) } @@ -2390,7 +2390,7 @@ test('Should accept custom querystring in the optons object', t => { querystring: { foo: 'bar' } }, (err, { body }) => { t.error(err) - t.deepEqual(body, { hello: 'world' }) + t.same(body, { hello: 'world' }) server.stop() }) }) @@ -2454,8 +2454,8 @@ test('Should pass request params and options to generateRequestId', t => { sniffInterval: false, sniffOnStart: false, generateRequestId: function (requestParams, requestOptions) { - t.deepEqual(requestParams, params) - t.deepEqual(requestOptions, options) + t.same(requestParams, params) + t.same(requestOptions, options) return 'id' } }) @@ -2489,8 +2489,8 @@ test('Secure json parsing', t => { method: 'GET', path: '/hello' }, (err, { body }) => { - t.true(err instanceof DeserializationError) - t.is(err.message, 'Object contains forbidden prototype property') + t.ok(err instanceof DeserializationError) + t.equal(err.message, 'Object contains forbidden prototype property') server.stop() }) }) @@ -2521,8 +2521,8 @@ test('Secure json parsing', t => { method: 'GET', path: '/hello' }, (err, { body }) => { - t.true(err instanceof DeserializationError) - t.is(err.message, 'Object contains forbidden prototype property') + t.ok(err instanceof DeserializationError) + t.equal(err.message, 'Object contains forbidden prototype property') server.stop() }) }) @@ -2535,7 +2535,7 @@ test('Lowercase headers utilty', t => { t.plan(4) const { lowerCaseHeaders } = Transport.internals - t.deepEqual(lowerCaseHeaders({ + t.same(lowerCaseHeaders({ Foo: 'bar', Faz: 'baz', 'X-Hello': 'world' @@ -2545,7 +2545,7 @@ test('Lowercase headers utilty', t => { 'x-hello': 'world' }) - t.deepEqual(lowerCaseHeaders({ + t.same(lowerCaseHeaders({ Foo: 'bar', faz: 'baz', 'X-hello': 'world' @@ -2555,9 +2555,9 @@ test('Lowercase headers utilty', t => { 'x-hello': 'world' }) - t.strictEqual(lowerCaseHeaders(null), null) + t.equal(lowerCaseHeaders(null), null) - t.strictEqual(lowerCaseHeaders(undefined), undefined) + t.equal(lowerCaseHeaders(undefined), undefined) }) test('The callback with a sync error should be called in the next tick - json', t => {