From 1691e7ad83dada3e1c85e968981e3195efcf571e Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 19 May 2021 10:51:08 +0200 Subject: [PATCH] =?UTF-8?q?chore(xo-collection):=20event-to-promise=20?= =?UTF-8?q?=E2=86=92=20promise-toolbox/fromEvent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/xo-collection/package.json | 2 +- packages/xo-collection/src/collection.spec.js | 20 +++++++++---------- packages/xo-collection/src/index.spec.js | 4 ++-- .../xo-collection/src/unique-index.spec.js | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/xo-collection/package.json b/packages/xo-collection/package.json index 81435fab5..5d2123493 100644 --- a/packages/xo-collection/package.json +++ b/packages/xo-collection/package.json @@ -30,7 +30,7 @@ "@babel/core": "^7.0.0", "@babel/preset-env": "^7.0.0", "cross-env": "^7.0.2", - "event-to-promise": "^0.8.0", + "promise-toolbox": "^0.19.2", "rimraf": "^3.0.0" }, "scripts": { diff --git a/packages/xo-collection/src/collection.spec.js b/packages/xo-collection/src/collection.spec.js index ced1a0ab1..44d54eea2 100644 --- a/packages/xo-collection/src/collection.spec.js +++ b/packages/xo-collection/src/collection.spec.js @@ -1,6 +1,6 @@ /* eslint-env jest */ -import eventToPromise from 'event-to-promise' +import fromEvent from 'promise-toolbox/fromEvent' import { forEach } from 'lodash' import Collection, { DuplicateItem, NoSuchItem } from './collection' @@ -69,7 +69,7 @@ describe('Collection', function () { expect(spy).not.toHaveBeenCalled() // Async event. - return eventToPromise(col, 'add').then(function (added) { + return fromEvent(col, 'add').then(function (added) { expect(Object.keys(added)).toEqual(['foo']) expect(added.foo).toBe(true) }) @@ -102,7 +102,7 @@ describe('Collection', function () { expect(spy).not.toHaveBeenCalled() // Async event. - return eventToPromise(col, 'update').then(function (updated) { + return fromEvent(col, 'update').then(function (updated) { expect(Object.keys(updated)).toEqual(['bar']) expect(updated.bar).toBe(2) }) @@ -134,7 +134,7 @@ describe('Collection', function () { expect(spy).not.toHaveBeenCalled() // Async event. - return eventToPromise(col, 'remove').then(function (removed) { + return fromEvent(col, 'remove').then(function (removed) { expect(Object.keys(removed)).toEqual(['bar']) expect(removed.bar).toBeUndefined() }) @@ -166,7 +166,7 @@ describe('Collection', function () { expect(spy).not.toHaveBeenCalled() // Async events. - return eventToPromise(col, 'add').then(function (added) { + return fromEvent(col, 'add').then(function (added) { expect(Object.keys(added)).toEqual(['foo']) expect(added.foo).toBe(true) }) @@ -184,7 +184,7 @@ describe('Collection', function () { expect(spy).not.toHaveBeenCalled() // Async events. - return eventToPromise(col, 'update').then(function (updated) { + return fromEvent(col, 'update').then(function (updated) { expect(Object.keys(updated)).toEqual(['bar']) expect(updated.bar).toBe(1) }) @@ -205,7 +205,7 @@ describe('Collection', function () { expect(col.has('bar')).toBe(false) - return eventToPromise(col, 'remove').then(function (removed) { + return fromEvent(col, 'remove').then(function (removed) { expect(Object.keys(removed)).toEqual(['bar']) expect(removed.bar).toBeUndefined() }) @@ -220,7 +220,7 @@ describe('Collection', function () { expect(col.has('bar')).toBe(false) - return eventToPromise(col, 'remove').then(function (removed) { + return fromEvent(col, 'remove').then(function (removed) { expect(Object.keys(removed)).toEqual(['bar']) expect(removed.bar).toBeUndefined() }) @@ -235,7 +235,7 @@ describe('Collection', function () { return waitTicks().then(() => { col.touch(foo) - return eventToPromise(col, 'update', items => { + return fromEvent(col, 'update', items => { expect(Object.keys(items)).toEqual(['foo']) expect(items.foo).toBe(foo) }) @@ -249,7 +249,7 @@ describe('Collection', function () { expect(col.size).toBe(0) - return eventToPromise(col, 'remove').then(items => { + return fromEvent(col, 'remove').then(items => { expect(Object.keys(items)).toEqual(['bar']) expect(items.bar).toBeUndefined() }) diff --git a/packages/xo-collection/src/index.spec.js b/packages/xo-collection/src/index.spec.js index deccbc6e1..96c57e601 100644 --- a/packages/xo-collection/src/index.spec.js +++ b/packages/xo-collection/src/index.spec.js @@ -1,6 +1,6 @@ /* eslint-env jest */ -import eventToPromise from 'event-to-promise' +import fromEvent from 'promise-toolbox/fromEvent' import { forEach } from 'lodash' import Collection from './collection' @@ -144,7 +144,7 @@ describe('Index', function () { col.update(item1bis) - return eventToPromise(col, 'finish').then(() => { + return fromEvent(col, 'finish').then(() => { expect(col.indexes).toEqual({ byGroup: { foo: { diff --git a/packages/xo-collection/src/unique-index.spec.js b/packages/xo-collection/src/unique-index.spec.js index 4ff9aa757..f9e51a3be 100644 --- a/packages/xo-collection/src/unique-index.spec.js +++ b/packages/xo-collection/src/unique-index.spec.js @@ -1,6 +1,6 @@ /* eslint-env jest */ -import eventToPromise from 'event-to-promise' +import fromEvent from 'promise-toolbox/fromEvent' import { forEach } from 'lodash' import Collection from './collection' @@ -119,7 +119,7 @@ describe('UniqueIndex', function () { col.update(item1bis) - return eventToPromise(col, 'finish').then(() => { + return fromEvent(col, 'finish').then(() => { expect(col.indexes).toEqual({ byKey: { [item1.key]: item1bis,