1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

Replace sinon with lolex

This commit is contained in:
Simen Bekkhus 2017-08-23 11:21:34 +02:00 committed by Ivar Conradi Østhus
parent 6df3ed6bc8
commit 3b260abbfe
5 changed files with 17 additions and 63 deletions

View File

@ -3,7 +3,7 @@
const { test } = require('ava');
const UnleashClientMetrics = require('./index');
const moment = require('moment');
const sinon = require('sinon');
const lolex = require('lolex');
const { EventEmitter } = require('events');
@ -21,7 +21,7 @@ test('should work without state', t => {
});
test.cb('data should expire', t => {
const clock = sinon.useFakeTimers();
const clock = lolex.install();
const store = new EventEmitter();
const metrics = new UnleashClientMetrics(store);
@ -59,7 +59,7 @@ test.cb('data should expire', t => {
t.true(lastMinExpires === 1);
t.true(lastHourExpires === 1);
clock.restore();
clock.uninstall();
t.end();
});
@ -183,7 +183,7 @@ test('should handle a lot of toggles', t => {
});
test('should have correct values for lastMinute', t => {
const clock = sinon.useFakeTimers();
const clock = lolex.install();
const store = new EventEmitter();
const metrics = new UnleashClientMetrics(store);
@ -251,11 +251,11 @@ test('should have correct values for lastMinute', t => {
t.deepEqual(c.lastMinute.toggle, { yes: 0, no: 0 });
metrics.destroy();
clock.restore();
clock.uninstall();
});
test('should have correct values for lastHour', t => {
const clock = sinon.useFakeTimers();
const clock = lolex.install();
const store = new EventEmitter();
const metrics = new UnleashClientMetrics(store);
@ -333,7 +333,7 @@ test('should have correct values for lastHour', t => {
t.deepEqual(c.lastHour.toggle, { yes: 0, no: 0 });
metrics.destroy();
clock.restore();
clock.uninstall();
});
test('should not fail when toggle metrics is missing yes/no field', t => {

View File

@ -3,7 +3,7 @@
const { test } = require('ava');
const TTLList = require('./ttl-list');
const moment = require('moment');
const sinon = require('sinon');
const lolex = require('lolex');
test.cb('should emit expire', t => {
const list = new TTLList({
@ -22,7 +22,7 @@ test.cb('should emit expire', t => {
});
test.cb('should slice off list', t => {
const clock = sinon.useFakeTimers();
const clock = lolex.install();
const list = new TTLList({
interval: 10,
@ -55,8 +55,7 @@ test.cb('should slice off list', t => {
t.true(expired.length === 4);
list.destroy();
clock.restore();
sinon.restore();
clock.uninstall();
t.end();
});

View File

@ -2,7 +2,7 @@
const { test } = require('ava');
const ClientMetricStore = require('./client-metrics-store');
const sinon = require('sinon');
const lolex = require('lolex');
function getMockDb() {
const list = [
@ -38,7 +38,7 @@ test.cb('should call database on startup', t => {
});
test.cb('should poll for updates', t => {
const clock = sinon.useFakeTimers();
const clock = lolex.install();
const mock = getMockDb();
const store = new ClientMetricStore(mock, 100);
@ -55,7 +55,7 @@ test.cb('should poll for updates', t => {
t.true(metrics.length === 4);
t.true(store.highestIdSeen === 4);
store.destroy();
clock.restore();
clock.uninstall();
t.end();
});
});

View File

@ -89,10 +89,10 @@
"eslint-config-finn-prettier": "^3.0.0",
"husky": "^0.14.1",
"lint-staged": "^4.0.0",
"lolex": "^2.1.2",
"nyc": "^11.0.3",
"prettier": "^1.5.2",
"proxyquire": "^1.7.11",
"sinon": "^2.3.5",
"superagent": "^3.5.0",
"supertest": "^3.0.0",
"supervisor": "^0.12.0"

View File

@ -1371,10 +1371,6 @@ detect-indent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d"
diff@^3.1.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.0.tgz#056695150d7aa93237ca7e378ac3b1682b7963b9"
disposables@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/disposables/-/disposables-1.0.1.tgz#064727a25b54f502bd82b89aa2dfb8df9f1b39e3"
@ -1898,12 +1894,6 @@ form-data@~2.1.1:
combined-stream "^1.0.5"
mime-types "^2.1.12"
formatio@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.2.0.tgz#f3b2167d9068c4698a8d51f4f760a39a54d818eb"
dependencies:
samsam "1.x"
formidable@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.1.1.tgz#96b8886f7c3c3508b932d6bd70c4d3a88f35f1a9"
@ -2967,9 +2957,9 @@ log4js@^1.0.1:
semver "^5.3.0"
streamroller "^0.4.0"
lolex@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.6.0.tgz#3a9a0283452a47d7439e72731b9e07d7386e49f6"
lolex@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.1.2.tgz#2694b953c9ea4d013e5b8bfba891c991025b2629"
longest@^1.0.1:
version "1.0.1"
@ -3175,10 +3165,6 @@ nan@^2.3.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45"
native-promise-only@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/native-promise-only/-/native-promise-only-0.8.1.tgz#20a318c30cb45f71fe7adfbf7b21c99c1472ef11"
natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
@ -3536,12 +3522,6 @@ path-to-regexp@0.1.7:
version "0.1.7"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
path-to-regexp@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
dependencies:
isarray "0.0.1"
path-type@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441"
@ -4296,10 +4276,6 @@ safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
samsam@1.x, samsam@^1.1.3:
version "1.2.1"
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.2.1.tgz#edd39093a3184370cb859243b2bdf255e7d8ea67"
scroll-behavior@^0.9.3:
version "0.9.3"
resolved "https://registry.yarnpkg.com/scroll-behavior/-/scroll-behavior-0.9.3.tgz#e48bcc8af364f3f07176e8dbca3968bd5e71557b"
@ -4388,19 +4364,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
sinon@^2.3.5:
version "2.4.1"
resolved "https://registry.yarnpkg.com/sinon/-/sinon-2.4.1.tgz#021fd64b54cb77d9d2fb0d43cdedfae7629c3a36"
dependencies:
diff "^3.1.0"
formatio "1.2.0"
lolex "^1.6.0"
native-promise-only "^0.8.1"
path-to-regexp "^1.7.0"
samsam "^1.1.3"
text-encoding "0.6.4"
type-detect "^4.0.0"
slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
@ -4742,10 +4705,6 @@ test-exclude@^4.1.1:
read-pkg-up "^1.0.1"
require-main-filename "^1.0.1"
text-encoding@0.6.4:
version "0.6.4"
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19"
text-table@^0.2.0, text-table@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
@ -4846,10 +4805,6 @@ type-check@~0.3.2:
dependencies:
prelude-ls "~1.1.2"
type-detect@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.3.tgz#0e3f2670b44099b0b46c284d136a7ef49c74c2ea"
type-is@~1.6.15:
version "1.6.15"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410"