From 2569890e31c84146b3fa1e7503e3f5e9ca466c3a Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 22 Jan 2020 09:29:35 -0500 Subject: [PATCH] refactor: move mockWarn utility to @vue/shared close #652 --- packages/compiler-sfc/__tests__/compileStyle.spec.ts | 2 +- packages/compiler-sfc/__tests__/parse.spec.ts | 2 +- packages/reactivity/__tests__/computed.spec.ts | 2 +- packages/reactivity/__tests__/reactive.spec.ts | 2 +- packages/reactivity/__tests__/readonly.spec.ts | 2 +- packages/runtime-core/__tests__/apiApp.spec.ts | 2 +- packages/runtime-core/__tests__/apiInject.spec.ts | 3 ++- packages/runtime-core/__tests__/apiOptions.spec.ts | 4 ++-- packages/runtime-core/__tests__/apiWatch.spec.ts | 3 ++- packages/runtime-core/__tests__/componentProxy.spec.ts | 8 ++------ packages/runtime-core/__tests__/errorHandling.spec.ts | 2 +- .../runtime-core/__tests__/helpers/resolveAssets.spec.ts | 2 +- .../runtime-core/__tests__/helpers/toHandlers.spec.ts | 2 +- .../__tests__/rendererAttrsFallthrough.spec.ts | 2 +- packages/runtime-core/__tests__/rendererChildren.spec.ts | 4 ++-- packages/runtime-test/__tests__/testRuntime.spec.ts | 4 ++-- packages/runtime-test/src/index.ts | 1 - packages/shared/src/index.ts | 1 + .../{runtime-test/src/utils => shared/src}/mockWarn.ts | 0 packages/vue/__tests__/index.spec.ts | 2 +- 20 files changed, 24 insertions(+), 26 deletions(-) rename packages/{runtime-test/src/utils => shared/src}/mockWarn.ts (100%) diff --git a/packages/compiler-sfc/__tests__/compileStyle.spec.ts b/packages/compiler-sfc/__tests__/compileStyle.spec.ts index 5198e7a7e34..b4af3c0972d 100644 --- a/packages/compiler-sfc/__tests__/compileStyle.spec.ts +++ b/packages/compiler-sfc/__tests__/compileStyle.spec.ts @@ -1,5 +1,5 @@ import { compileStyle } from '../src/compileStyle' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' function compile(source: string): string { const res = compileStyle({ diff --git a/packages/compiler-sfc/__tests__/parse.spec.ts b/packages/compiler-sfc/__tests__/parse.spec.ts index affe1f5a368..a55e2e6b288 100644 --- a/packages/compiler-sfc/__tests__/parse.spec.ts +++ b/packages/compiler-sfc/__tests__/parse.spec.ts @@ -1,5 +1,5 @@ import { parse } from '../src' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' import { baseParse, baseCompile } from '@vue/compiler-core' describe('compiler:sfc', () => { diff --git a/packages/reactivity/__tests__/computed.spec.ts b/packages/reactivity/__tests__/computed.spec.ts index 0ab644af7f1..5ab4641e988 100644 --- a/packages/reactivity/__tests__/computed.spec.ts +++ b/packages/reactivity/__tests__/computed.spec.ts @@ -6,7 +6,7 @@ import { ref, WritableComputedRef } from '../src' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' describe('reactivity/computed', () => { mockWarn() diff --git a/packages/reactivity/__tests__/reactive.spec.ts b/packages/reactivity/__tests__/reactive.spec.ts index 2d134922d3a..62913e67063 100644 --- a/packages/reactivity/__tests__/reactive.spec.ts +++ b/packages/reactivity/__tests__/reactive.spec.ts @@ -1,6 +1,6 @@ import { ref, isRef } from '../src/ref' import { reactive, isReactive, toRaw, markNonReactive } from '../src/reactive' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' import { computed } from '../src/computed' describe('reactivity/reactive', () => { diff --git a/packages/reactivity/__tests__/readonly.spec.ts b/packages/reactivity/__tests__/readonly.spec.ts index bcd1c43ec7f..e009022d08c 100644 --- a/packages/reactivity/__tests__/readonly.spec.ts +++ b/packages/reactivity/__tests__/readonly.spec.ts @@ -12,7 +12,7 @@ import { ref, shallowReadonly } from '../src' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' /** * @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html diff --git a/packages/runtime-core/__tests__/apiApp.spec.ts b/packages/runtime-core/__tests__/apiApp.spec.ts index 7ade99e9e94..6fb8239b8f9 100644 --- a/packages/runtime-core/__tests__/apiApp.spec.ts +++ b/packages/runtime-core/__tests__/apiApp.spec.ts @@ -3,7 +3,6 @@ import { h, nodeOps, serializeInner, - mockWarn, provide, inject, resolveComponent, @@ -13,6 +12,7 @@ import { ref, getCurrentInstance } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' describe('api: createApp', () => { mockWarn() diff --git a/packages/runtime-core/__tests__/apiInject.spec.ts b/packages/runtime-core/__tests__/apiInject.spec.ts index 26359fe4c1a..d979861a82b 100644 --- a/packages/runtime-core/__tests__/apiInject.spec.ts +++ b/packages/runtime-core/__tests__/apiInject.spec.ts @@ -9,7 +9,8 @@ import { readonly, reactive } from '../src/index' -import { render, nodeOps, serialize, mockWarn } from '@vue/runtime-test' +import { render, nodeOps, serialize } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' // reference: https://vue-composition-api-rfc.netlify.com/api.html#provide-inject diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index 8a0199e3ffb..7d915eb0ff2 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -8,9 +8,9 @@ import { nextTick, renderToString, ref, - defineComponent, - mockWarn + defineComponent } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' describe('api: options', () => { test('data', async () => { diff --git a/packages/runtime-core/__tests__/apiWatch.spec.ts b/packages/runtime-core/__tests__/apiWatch.spec.ts index 15a0765f97e..ad8f4787145 100644 --- a/packages/runtime-core/__tests__/apiWatch.spec.ts +++ b/packages/runtime-core/__tests__/apiWatch.spec.ts @@ -1,11 +1,12 @@ import { watch, reactive, computed, nextTick, ref, h } from '../src/index' -import { render, nodeOps, serializeInner, mockWarn } from '@vue/runtime-test' +import { render, nodeOps, serializeInner } from '@vue/runtime-test' import { ITERATE_KEY, DebuggerEvent, TrackOpTypes, TriggerOpTypes } from '@vue/reactivity' +import { mockWarn } from '@vue/shared' // reference: https://vue-composition-api-rfc.netlify.com/api.html#watch diff --git a/packages/runtime-core/__tests__/componentProxy.spec.ts b/packages/runtime-core/__tests__/componentProxy.spec.ts index 2014cd2f8e5..ddfd8cab0bf 100644 --- a/packages/runtime-core/__tests__/componentProxy.spec.ts +++ b/packages/runtime-core/__tests__/componentProxy.spec.ts @@ -1,9 +1,5 @@ -import { - createApp, - getCurrentInstance, - nodeOps, - mockWarn -} from '@vue/runtime-test' +import { createApp, getCurrentInstance, nodeOps } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' import { ComponentInternalInstance } from '../src/component' describe('component: proxy', () => { diff --git a/packages/runtime-core/__tests__/errorHandling.spec.ts b/packages/runtime-core/__tests__/errorHandling.spec.ts index be809d5ff98..d9f753f9330 100644 --- a/packages/runtime-core/__tests__/errorHandling.spec.ts +++ b/packages/runtime-core/__tests__/errorHandling.spec.ts @@ -7,10 +7,10 @@ import { watch, ref, nextTick, - mockWarn, defineComponent } from '@vue/runtime-test' import { setErrorRecovery } from '../src/errorHandling' +import { mockWarn } from '@vue/shared' describe('error handling', () => { mockWarn() diff --git a/packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts b/packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts index cfa4a3e23d1..392311c1cb5 100644 --- a/packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts +++ b/packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts @@ -1,5 +1,4 @@ import { - mockWarn, createApp, nodeOps, resolveComponent, @@ -9,6 +8,7 @@ import { resolveDynamicComponent, getCurrentInstance } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' describe('resolveAssets', () => { test('should work', () => { diff --git a/packages/runtime-core/__tests__/helpers/toHandlers.spec.ts b/packages/runtime-core/__tests__/helpers/toHandlers.spec.ts index e07cf141699..000f9004952 100644 --- a/packages/runtime-core/__tests__/helpers/toHandlers.spec.ts +++ b/packages/runtime-core/__tests__/helpers/toHandlers.spec.ts @@ -1,5 +1,5 @@ import { toHandlers } from '../../src/helpers/toHandlers' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' describe('toHandlers', () => { mockWarn() diff --git a/packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts b/packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts index fed38fc3f3a..fe34eee6010 100644 --- a/packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts +++ b/packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts @@ -8,7 +8,7 @@ import { onUpdated, defineComponent } from '@vue/runtime-dom' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' describe('attribute fallthrough', () => { mockWarn() diff --git a/packages/runtime-core/__tests__/rendererChildren.spec.ts b/packages/runtime-core/__tests__/rendererChildren.spec.ts index 553d73b5e75..93ef3b99b73 100644 --- a/packages/runtime-core/__tests__/rendererChildren.spec.ts +++ b/packages/runtime-core/__tests__/rendererChildren.spec.ts @@ -6,9 +6,9 @@ import { NodeTypes, TestElement, serialize, - serializeInner, - mockWarn + serializeInner } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' mockWarn() diff --git a/packages/runtime-test/__tests__/testRuntime.spec.ts b/packages/runtime-test/__tests__/testRuntime.spec.ts index ec7cbb21eea..be18d4a00a2 100644 --- a/packages/runtime-test/__tests__/testRuntime.spec.ts +++ b/packages/runtime-test/__tests__/testRuntime.spec.ts @@ -12,9 +12,9 @@ import { NodeOpTypes, nextTick, serialize, - triggerEvent, - mockWarn + triggerEvent } from '../src' +import { mockWarn } from '@vue/shared' describe('test renderer', () => { mockWarn() diff --git a/packages/runtime-test/src/index.ts b/packages/runtime-test/src/index.ts index 96c3ad1eb3e..c057da7e018 100644 --- a/packages/runtime-test/src/index.ts +++ b/packages/runtime-test/src/index.ts @@ -26,5 +26,4 @@ export function renderToString(vnode: VNode) { export * from './triggerEvent' export * from './serialize' export * from './nodeOps' -export * from './utils/mockWarn' export * from '@vue/runtime-core' diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index de6596198e7..4d6f700166f 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -5,6 +5,7 @@ export * from './patchFlags' export * from './globalsWhitelist' export * from './codeframe' export * from './domTagConfig' +export * from './mockWarn' export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__ ? Object.freeze({}) diff --git a/packages/runtime-test/src/utils/mockWarn.ts b/packages/shared/src/mockWarn.ts similarity index 100% rename from packages/runtime-test/src/utils/mockWarn.ts rename to packages/shared/src/mockWarn.ts diff --git a/packages/vue/__tests__/index.spec.ts b/packages/vue/__tests__/index.spec.ts index 7b732528bd5..4a7a06bb64d 100644 --- a/packages/vue/__tests__/index.spec.ts +++ b/packages/vue/__tests__/index.spec.ts @@ -1,5 +1,5 @@ import { createApp } from '../src' -import { mockWarn } from '@vue/runtime-test' +import { mockWarn } from '@vue/shared' describe('compiler + runtime integration', () => { mockWarn()