Skip to content

Commit

Permalink
⬆️ Update faked-promise
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jan 28, 2018
1 parent e52004c commit a5f90ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"codecov": "^3.0.0",
"eslint": "^4.16.0",
"eslint-config-posva": "^1.3.2",
"faked-promise": "^1.0.0",
"faked-promise": "^2.0.0",
"jest": "^22.1.4",
"vue": "^2.5.13",
"vue-jest": "^2.0.0",
Expand Down
16 changes: 7 additions & 9 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ describe('Promised', () => {
let wrapper
describe('single promise', () => {
let promise, resolve, reject
beforeEach(async () => {
[promise, resolve, reject] = await fakePromise()
beforeEach(() => {
[promise, resolve, reject] = fakePromise()
wrapper = mount(Helper, {
propsData: {
promise,
Expand All @@ -34,15 +34,15 @@ describe('Promised', () => {
})

test('cancels previous promise', async () => {
const other = await fakePromise()
const other = fakePromise()
wrapper.setProps({ promise: other[0] })
resolve('foo')
await tick()
expect(wrapper.text()).toBe('loading')
})

test('cancels previous rejected promise', async () => {
const other = await fakePromise()
const other = fakePromise()
wrapper.setProps({ promise: other[0] })
reject(new Error('failed'))
await tick()
Expand All @@ -53,9 +53,7 @@ describe('Promised', () => {
describe('multiple promise', () => {
let fakedPromises
beforeEach(async () => {
fakedPromises = (await Promise.all(
Array.from({ length: 3 }, () => fakePromise())
)).map(([promise, resolve, reject]) => ({
fakedPromises = Array.from({ length: 3 }, () => fakePromise()).map(([promise, resolve, reject]) => ({
promise,
resolve,
reject,
Expand Down Expand Up @@ -94,15 +92,15 @@ describe('Promised', () => {
})

test('cancels previous promise', async () => {
const other = await fakePromise()
const other = fakePromise()
wrapper.setProps({ promises: [other[0]] })
fakedPromises[0].resolve('foo')
await tick()
expect(wrapper.text()).toBe('loading')
})

test('cancels previous rejected promise', async () => {
const other = await fakePromise()
const other = fakePromise()
wrapper.setProps({ promises: [other[0]] })
fakedPromises[0].reject(new Error('failed'))
await tick()
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1470,9 +1470,9 @@ extsprintf@^1.2.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"

faked-promise@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/faked-promise/-/faked-promise-1.0.0.tgz#5b7e93c422be46d9bdd1f8ae1293cb709ca352c0"
faked-promise@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/faked-promise/-/faked-promise-2.0.0.tgz#57f929e4363deee7debb4d3242d4ab0c607cdfaa"

fast-deep-equal@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit a5f90ac

Please sign in to comment.