Skip to content

Commit e21852e

Browse files
authored
Merge pull request #155 from cuixiaorui/remove-shapeFlags
chore: remove ShapeFlags
2 parents 26fbc88 + 3e03e87 commit e21852e

File tree

8 files changed

+20
-27
lines changed

8 files changed

+20
-27
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"babel-jest": "^25.2.3",
2828
"babel-preset-jest": "^25.2.1",
2929
"dom-event-types": "^1.0.0",
30-
"flush-promises": "^1.0.2",
3130
"husky": "^4.2.3",
3231
"jest": "^25.1.0",
3332
"jsdom": "^16.2.2",

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,14 @@ import { RouterLinkStub } from './components/RouterLinkStub'
33
import { VueWrapper } from './vueWrapper'
44
import { DOMWrapper } from './domWrapper'
55
import { config } from './config'
6+
import { flushPromises } from './utils/flushPromises'
67

7-
export { mount, shallowMount, RouterLinkStub, VueWrapper, DOMWrapper, config }
8+
export {
9+
mount,
10+
shallowMount,
11+
RouterLinkStub,
12+
VueWrapper,
13+
DOMWrapper,
14+
config,
15+
flushPromises
16+
}

src/utils/flushPromises.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout
2+
3+
export function flushPromises() {
4+
return new Promise((resolve) => {
5+
scheduler(resolve, 0)
6+
})
7+
}

src/utils/vueShared.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,3 @@ const hyphenateRE = /\B([A-Z])/g
1919
export const hyphenate = cacheStringFunction((str: string): string => {
2020
return str.replace(hyphenateRE, '-$1').toLowerCase()
2121
})
22-
23-
export const enum ShapeFlags {
24-
ELEMENT = 1,
25-
FUNCTIONAL_COMPONENT = 1 << 1,
26-
STATEFUL_COMPONENT = 1 << 2,
27-
TEXT_CHILDREN = 1 << 3,
28-
ARRAY_CHILDREN = 1 << 4,
29-
SLOTS_CHILDREN = 1 << 5,
30-
TELEPORT = 1 << 6,
31-
SUSPENSE = 1 << 7,
32-
COMPONENT_SHOULD_KEEP_ALIVE = 1 << 8,
33-
COMPONENT_KEPT_ALIVE = 1 << 9,
34-
COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT
35-
}

src/vueWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentPublicInstance, nextTick, App } from 'vue'
2-
import { ShapeFlags } from './utils/vueShared'
2+
import { ShapeFlags } from '@vue/shared'
33
import { config } from './config'
44

55
import { DOMWrapper } from './domWrapper'

tests/features/async-components.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { defineAsyncComponent, defineComponent, h, AppConfig } from 'vue'
2-
import flushPromises from 'flush-promises'
32

4-
import { mount } from '../../src'
3+
import { mount, flushPromises } from '../../src'
54

65
const config: AppConfig = {
76
devtools: false,

tests/features/suspense.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import flushPromises from 'flush-promises'
2-
31
import SuspenseComponent from '../components/Suspense.vue'
4-
import { mount } from '../../src'
2+
import { mount, flushPromises } from '../../src'
53

64
let mockShouldError = false
75
jest.mock('../utils', () => ({

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,11 +2572,6 @@ find-versions@^3.2.0:
25722572
dependencies:
25732573
semver-regex "^2.0.0"
25742574

2575-
flush-promises@^1.0.2:
2576-
version "1.0.2"
2577-
resolved "https://registry.yarnpkg.com/flush-promises/-/flush-promises-1.0.2.tgz#4948fd58f15281fed79cbafc86293d5bb09b2ced"
2578-
integrity sha512-G0sYfLQERwKz4+4iOZYQEZVpOt9zQrlItIxQAAYAWpfby3gbHrx0osCHz5RLl/XoXevXk0xoN4hDFky/VV9TrA==
2579-
25802575
for-in@^1.0.2:
25812576
version "1.0.2"
25822577
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"

0 commit comments

Comments
 (0)