chore(xo-collection): event-to-promise → promise-toolbox/fromEvent
This commit is contained in:
parent
6c2cb31923
commit
1691e7ad83
@ -30,7 +30,7 @@
|
|||||||
"@babel/core": "^7.0.0",
|
"@babel/core": "^7.0.0",
|
||||||
"@babel/preset-env": "^7.0.0",
|
"@babel/preset-env": "^7.0.0",
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"event-to-promise": "^0.8.0",
|
"promise-toolbox": "^0.19.2",
|
||||||
"rimraf": "^3.0.0"
|
"rimraf": "^3.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
|
|
||||||
import eventToPromise from 'event-to-promise'
|
import fromEvent from 'promise-toolbox/fromEvent'
|
||||||
import { forEach } from 'lodash'
|
import { forEach } from 'lodash'
|
||||||
|
|
||||||
import Collection, { DuplicateItem, NoSuchItem } from './collection'
|
import Collection, { DuplicateItem, NoSuchItem } from './collection'
|
||||||
@ -69,7 +69,7 @@ describe('Collection', function () {
|
|||||||
expect(spy).not.toHaveBeenCalled()
|
expect(spy).not.toHaveBeenCalled()
|
||||||
|
|
||||||
// Async event.
|
// Async event.
|
||||||
return eventToPromise(col, 'add').then(function (added) {
|
return fromEvent(col, 'add').then(function (added) {
|
||||||
expect(Object.keys(added)).toEqual(['foo'])
|
expect(Object.keys(added)).toEqual(['foo'])
|
||||||
expect(added.foo).toBe(true)
|
expect(added.foo).toBe(true)
|
||||||
})
|
})
|
||||||
@ -102,7 +102,7 @@ describe('Collection', function () {
|
|||||||
expect(spy).not.toHaveBeenCalled()
|
expect(spy).not.toHaveBeenCalled()
|
||||||
|
|
||||||
// Async event.
|
// Async event.
|
||||||
return eventToPromise(col, 'update').then(function (updated) {
|
return fromEvent(col, 'update').then(function (updated) {
|
||||||
expect(Object.keys(updated)).toEqual(['bar'])
|
expect(Object.keys(updated)).toEqual(['bar'])
|
||||||
expect(updated.bar).toBe(2)
|
expect(updated.bar).toBe(2)
|
||||||
})
|
})
|
||||||
@ -134,7 +134,7 @@ describe('Collection', function () {
|
|||||||
expect(spy).not.toHaveBeenCalled()
|
expect(spy).not.toHaveBeenCalled()
|
||||||
|
|
||||||
// Async event.
|
// Async event.
|
||||||
return eventToPromise(col, 'remove').then(function (removed) {
|
return fromEvent(col, 'remove').then(function (removed) {
|
||||||
expect(Object.keys(removed)).toEqual(['bar'])
|
expect(Object.keys(removed)).toEqual(['bar'])
|
||||||
expect(removed.bar).toBeUndefined()
|
expect(removed.bar).toBeUndefined()
|
||||||
})
|
})
|
||||||
@ -166,7 +166,7 @@ describe('Collection', function () {
|
|||||||
expect(spy).not.toHaveBeenCalled()
|
expect(spy).not.toHaveBeenCalled()
|
||||||
|
|
||||||
// Async events.
|
// Async events.
|
||||||
return eventToPromise(col, 'add').then(function (added) {
|
return fromEvent(col, 'add').then(function (added) {
|
||||||
expect(Object.keys(added)).toEqual(['foo'])
|
expect(Object.keys(added)).toEqual(['foo'])
|
||||||
expect(added.foo).toBe(true)
|
expect(added.foo).toBe(true)
|
||||||
})
|
})
|
||||||
@ -184,7 +184,7 @@ describe('Collection', function () {
|
|||||||
expect(spy).not.toHaveBeenCalled()
|
expect(spy).not.toHaveBeenCalled()
|
||||||
|
|
||||||
// Async events.
|
// Async events.
|
||||||
return eventToPromise(col, 'update').then(function (updated) {
|
return fromEvent(col, 'update').then(function (updated) {
|
||||||
expect(Object.keys(updated)).toEqual(['bar'])
|
expect(Object.keys(updated)).toEqual(['bar'])
|
||||||
expect(updated.bar).toBe(1)
|
expect(updated.bar).toBe(1)
|
||||||
})
|
})
|
||||||
@ -205,7 +205,7 @@ describe('Collection', function () {
|
|||||||
|
|
||||||
expect(col.has('bar')).toBe(false)
|
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(Object.keys(removed)).toEqual(['bar'])
|
||||||
expect(removed.bar).toBeUndefined()
|
expect(removed.bar).toBeUndefined()
|
||||||
})
|
})
|
||||||
@ -220,7 +220,7 @@ describe('Collection', function () {
|
|||||||
|
|
||||||
expect(col.has('bar')).toBe(false)
|
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(Object.keys(removed)).toEqual(['bar'])
|
||||||
expect(removed.bar).toBeUndefined()
|
expect(removed.bar).toBeUndefined()
|
||||||
})
|
})
|
||||||
@ -235,7 +235,7 @@ describe('Collection', function () {
|
|||||||
return waitTicks().then(() => {
|
return waitTicks().then(() => {
|
||||||
col.touch(foo)
|
col.touch(foo)
|
||||||
|
|
||||||
return eventToPromise(col, 'update', items => {
|
return fromEvent(col, 'update', items => {
|
||||||
expect(Object.keys(items)).toEqual(['foo'])
|
expect(Object.keys(items)).toEqual(['foo'])
|
||||||
expect(items.foo).toBe(foo)
|
expect(items.foo).toBe(foo)
|
||||||
})
|
})
|
||||||
@ -249,7 +249,7 @@ describe('Collection', function () {
|
|||||||
|
|
||||||
expect(col.size).toBe(0)
|
expect(col.size).toBe(0)
|
||||||
|
|
||||||
return eventToPromise(col, 'remove').then(items => {
|
return fromEvent(col, 'remove').then(items => {
|
||||||
expect(Object.keys(items)).toEqual(['bar'])
|
expect(Object.keys(items)).toEqual(['bar'])
|
||||||
expect(items.bar).toBeUndefined()
|
expect(items.bar).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
|
|
||||||
import eventToPromise from 'event-to-promise'
|
import fromEvent from 'promise-toolbox/fromEvent'
|
||||||
import { forEach } from 'lodash'
|
import { forEach } from 'lodash'
|
||||||
|
|
||||||
import Collection from './collection'
|
import Collection from './collection'
|
||||||
@ -144,7 +144,7 @@ describe('Index', function () {
|
|||||||
|
|
||||||
col.update(item1bis)
|
col.update(item1bis)
|
||||||
|
|
||||||
return eventToPromise(col, 'finish').then(() => {
|
return fromEvent(col, 'finish').then(() => {
|
||||||
expect(col.indexes).toEqual({
|
expect(col.indexes).toEqual({
|
||||||
byGroup: {
|
byGroup: {
|
||||||
foo: {
|
foo: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
|
|
||||||
import eventToPromise from 'event-to-promise'
|
import fromEvent from 'promise-toolbox/fromEvent'
|
||||||
import { forEach } from 'lodash'
|
import { forEach } from 'lodash'
|
||||||
|
|
||||||
import Collection from './collection'
|
import Collection from './collection'
|
||||||
@ -119,7 +119,7 @@ describe('UniqueIndex', function () {
|
|||||||
|
|
||||||
col.update(item1bis)
|
col.update(item1bis)
|
||||||
|
|
||||||
return eventToPromise(col, 'finish').then(() => {
|
return fromEvent(col, 'finish').then(() => {
|
||||||
expect(col.indexes).toEqual({
|
expect(col.indexes).toEqual({
|
||||||
byKey: {
|
byKey: {
|
||||||
[item1.key]: item1bis,
|
[item1.key]: item1bis,
|
||||||
|
Loading…
Reference in New Issue
Block a user