Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 7 additions & 0 deletions src/utils/flushPromises.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout

export function flushPromises() {
return new Promise((resolve) => {
scheduler(resolve, 0)
})
}
14 changes: 0 additions & 14 deletions src/utils/vueShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/vueWrapper.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 1 addition & 2 deletions tests/features/async-components.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 1 addition & 3 deletions tests/features/suspense.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => ({
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down