From 93cf8aa3c0cd8e98a4459c18c8a982d9b3f21d60 Mon Sep 17 00:00:00 2001 From: Alexander Mykolaichuk Date: Mon, 8 Jun 2020 09:37:29 +0200 Subject: [PATCH] migrated to FakeTimers (#1221) --- package.json | 1 - test/behavior/observability.test.js | 8 ++++---- test/behavior/resurrect.test.js | 8 ++++---- test/behavior/sniff.test.js | 4 ++-- test/unit/transport.test.js | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index fef9013cc..601ef7838 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "into-stream": "^5.1.1", "js-yaml": "^3.13.1", "license-checker": "^25.0.1", - "lolex": "^4.0.1", "minimist": "^1.2.0", "ora": "^3.4.0", "pretty-hrtime": "^1.0.3", diff --git a/test/behavior/observability.test.js b/test/behavior/observability.test.js index 65c16ca6d..491e0817a 100644 --- a/test/behavior/observability.test.js +++ b/test/behavior/observability.test.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('tap') -const lolex = require('lolex') +const FakeTimers = require('@sinonjs/fake-timers') const { Client, Transport } = require('../../index') const { connection: { MockConnection, MockConnectionSniff } @@ -125,7 +125,7 @@ test('Request id', t => { t.test('Resurrect should use the same request id of the request that starts it', t => { t.plan(2) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection, @@ -281,7 +281,7 @@ test('Client name', t => { t.test('Resurrect should have the client name configured', t => { t.plan(2) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection, @@ -305,7 +305,7 @@ test('Client name', t => { t.test('Resurrect should have the client name configured (child client)', t => { t.plan(2) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection, diff --git a/test/behavior/resurrect.test.js b/test/behavior/resurrect.test.js index 28ba78e87..40f316d94 100644 --- a/test/behavior/resurrect.test.js +++ b/test/behavior/resurrect.test.js @@ -6,7 +6,7 @@ const { test } = require('tap') const { URL } = require('url') -const lolex = require('lolex') +const FakeTimers = require('@sinonjs/fake-timers') const workq = require('workq') const { buildCluster } = require('../utils') const { Client, events } = require('../../index') @@ -24,7 +24,7 @@ const { Client, events } = require('../../index') test('Should execute the recurrect API with the ping strategy', t => { t.plan(8) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) const q = workq() buildCluster({ numberOfNodes: 2 }, cluster => { @@ -77,7 +77,7 @@ test('Should execute the recurrect API with the ping strategy', t => { test('Resurrect a node and handle 502/3/4 status code', t => { t.plan(15) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) const q = workq() var count = 0 @@ -146,7 +146,7 @@ test('Resurrect a node and handle 502/3/4 status code', t => { test('Should execute the recurrect API with the optimistic strategy', t => { t.plan(8) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) const q = workq() buildCluster({ numberOfNodes: 2 }, cluster => { diff --git a/test/behavior/sniff.test.js b/test/behavior/sniff.test.js index 5bbb2a438..065e424ac 100644 --- a/test/behavior/sniff.test.js +++ b/test/behavior/sniff.test.js @@ -6,7 +6,7 @@ const { test } = require('tap') const { URL } = require('url') -const lolex = require('lolex') +const FakeTimers = require('@sinonjs/fake-timers') const workq = require('workq') const { buildCluster } = require('../utils') const { Client, Connection, Transport, events, errors } = require('../../index') @@ -115,7 +115,7 @@ test('Should handle hostnames in publish_address', t => { test('Sniff interval', t => { t.plan(11) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) const q = workq() buildCluster(({ nodes, shutdown, kill }) => { diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index e3875b291..bdd9bdeb2 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -6,7 +6,7 @@ const { test } = require('tap') const { URL } = require('url') -const lolex = require('lolex') +const FakeTimers = require('@sinonjs/fake-timers') const { createGunzip } = require('zlib') const os = require('os') const intoStream = require('into-stream') @@ -1072,7 +1072,7 @@ test('sniff', t => { t.test('sniffInterval', t => { t.plan(6) - const clock = lolex.install({ toFake: ['Date'] }) + const clock = FakeTimers.install({ toFake: ['Date'] }) t.teardown(() => clock.uninstall()) class MyTransport extends Transport {