diff --git a/package.json b/package.json index e1b2b9c59..ed40d7c23 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "babel-jest": "^25.2.3", "babel-preset-jest": "^25.2.1", "dom-event-types": "^1.0.0", - "flush-promises": "^1.0.2", "husky": "^4.2.3", "jest": "^25.1.0", "jsdom": "^16.2.2", diff --git a/src/index.ts b/src/index.ts index d28e345f2..5f19a9ce3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,5 +3,14 @@ import { RouterLinkStub } from './components/RouterLinkStub' import { VueWrapper } from './vueWrapper' import { DOMWrapper } from './domWrapper' import { config } from './config' +import { flushPromises } from './utils/flushPromises' -export { mount, shallowMount, RouterLinkStub, VueWrapper, DOMWrapper, config } +export { + mount, + shallowMount, + RouterLinkStub, + VueWrapper, + DOMWrapper, + config, + flushPromises +} diff --git a/src/utils/flushPromises.ts b/src/utils/flushPromises.ts new file mode 100644 index 000000000..05315fa52 --- /dev/null +++ b/src/utils/flushPromises.ts @@ -0,0 +1,7 @@ +const scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout + +export function flushPromises() { + return new Promise((resolve) => { + scheduler(resolve, 0) + }) +} diff --git a/src/utils/vueShared.ts b/src/utils/vueShared.ts index 25d7ac8cf..2214494b5 100644 --- a/src/utils/vueShared.ts +++ b/src/utils/vueShared.ts @@ -19,17 +19,3 @@ const hyphenateRE = /\B([A-Z])/g export const hyphenate = cacheStringFunction((str: string): string => { return str.replace(hyphenateRE, '-$1').toLowerCase() }) - -export const enum ShapeFlags { - ELEMENT = 1, - FUNCTIONAL_COMPONENT = 1 << 1, - STATEFUL_COMPONENT = 1 << 2, - TEXT_CHILDREN = 1 << 3, - ARRAY_CHILDREN = 1 << 4, - SLOTS_CHILDREN = 1 << 5, - TELEPORT = 1 << 6, - SUSPENSE = 1 << 7, - COMPONENT_SHOULD_KEEP_ALIVE = 1 << 8, - COMPONENT_KEPT_ALIVE = 1 << 9, - COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT -} diff --git a/src/vueWrapper.ts b/src/vueWrapper.ts index c073d6ff6..bf0f8fcc9 100644 --- a/src/vueWrapper.ts +++ b/src/vueWrapper.ts @@ -1,5 +1,5 @@ import { ComponentPublicInstance, nextTick, App } from 'vue' -import { ShapeFlags } from './utils/vueShared' +import { ShapeFlags } from '@vue/shared' import { config } from './config' import { DOMWrapper } from './domWrapper' diff --git a/tests/features/async-components.spec.ts b/tests/features/async-components.spec.ts index e829668a5..bc26ed57c 100644 --- a/tests/features/async-components.spec.ts +++ b/tests/features/async-components.spec.ts @@ -1,7 +1,6 @@ import { defineAsyncComponent, defineComponent, h, AppConfig } from 'vue' -import flushPromises from 'flush-promises' -import { mount } from '../../src' +import { mount, flushPromises } from '../../src' const config: AppConfig = { devtools: false, diff --git a/tests/features/suspense.spec.ts b/tests/features/suspense.spec.ts index d4f6f354e..1338fbce4 100644 --- a/tests/features/suspense.spec.ts +++ b/tests/features/suspense.spec.ts @@ -1,7 +1,5 @@ -import flushPromises from 'flush-promises' - import SuspenseComponent from '../components/Suspense.vue' -import { mount } from '../../src' +import { mount, flushPromises } from '../../src' let mockShouldError = false jest.mock('../utils', () => ({ diff --git a/yarn.lock b/yarn.lock index 3d5e24308..245846c8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2572,11 +2572,6 @@ find-versions@^3.2.0: dependencies: semver-regex "^2.0.0" -flush-promises@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/flush-promises/-/flush-promises-1.0.2.tgz#4948fd58f15281fed79cbafc86293d5bb09b2ced" - integrity sha512-G0sYfLQERwKz4+4iOZYQEZVpOt9zQrlItIxQAAYAWpfby3gbHrx0osCHz5RLl/XoXevXk0xoN4hDFky/VV9TrA== - for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"