chore(xo-collection): event-to-promise → promise-toolbox/fromEvent

This commit is contained in:
Julien Fontanet 2021-05-19 10:51:08 +02:00
parent 6c2cb31923
commit 1691e7ad83
4 changed files with 15 additions and 15 deletions

View File

@ -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": {

View File

@ -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()
})

View File

@ -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: {

View File

@ -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,