test: move mockWarn into setup files

This commit is contained in:
Evan You
2020-07-27 22:58:37 -04:00
parent d4527230e4
commit 5c74243211
35 changed files with 103 additions and 199 deletions

View File

@@ -13,11 +13,8 @@ import {
getCurrentInstance,
defineComponent
} from '@vue/runtime-test'
import { mockWarn } from '@vue/shared'
describe('api: createApp', () => {
mockWarn()
test('mount', () => {
const Comp = defineComponent({
props: {

View File

@@ -10,13 +10,9 @@ import {
reactive
} from '../src/index'
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
describe('api: provide/inject', () => {
mockWarn()
it('string keys', () => {
const Provider = {
setup() {

View File

@@ -10,7 +10,6 @@ import {
ref,
defineComponent
} from '@vue/runtime-test'
import { mockWarn } from '@vue/shared'
describe('api: options', () => {
test('data', async () => {
@@ -705,8 +704,6 @@ describe('api: options', () => {
})
describe('warnings', () => {
mockWarn()
test('Expected a function as watch handler', () => {
const Comp = {
watch: {

View File

@@ -14,13 +14,10 @@ import {
TrackOpTypes,
TriggerOpTypes
} from '@vue/reactivity'
import { mockWarn } from '@vue/shared'
// reference: https://vue-composition-api-rfc.netlify.com/api.html#watch
describe('api: watch', () => {
mockWarn()
it('effect', async () => {
const state = reactive({ count: 0 })
let dummy

View File

@@ -1,13 +1,10 @@
// Note: emits and listener fallthrough is tested in
// ./rendererAttrsFallthrough.spec.ts.
import { mockWarn } from '@vue/shared'
import { render, defineComponent, h, nodeOps } from '@vue/runtime-test'
import { isEmitListener } from '../src/componentEmits'
describe('component: emit', () => {
mockWarn()
test('trigger handlers', () => {
const Foo = defineComponent({
render() {},

View File

@@ -10,11 +10,8 @@ import {
serializeInner
} from '@vue/runtime-test'
import { render as domRender, nextTick } from 'vue'
import { mockWarn } from '@vue/shared'
describe('component props', () => {
mockWarn()
test('stateful', () => {
let props: any
let attrs: any

View File

@@ -6,12 +6,9 @@ import {
createApp,
shallowReadonly
} from '@vue/runtime-test'
import { mockWarn } from '@vue/shared'
import { ComponentInternalInstance } from '../src/component'
describe('component: proxy', () => {
mockWarn()
test('data', () => {
let instance: ComponentInternalInstance
let instanceProxy: any

View File

@@ -11,11 +11,8 @@ import {
watchEffect
} from '@vue/runtime-test'
import { setErrorRecovery } from '../src/errorHandling'
import { mockWarn } from '@vue/shared'
describe('error handling', () => {
mockWarn()
beforeEach(() => {
setErrorRecovery(true)
})

View File

@@ -1,9 +1,7 @@
import { renderSlot } from '../../src/helpers/renderSlot'
import { h } from '../../src/h'
import { mockWarn } from '@vue/shared'
describe('renderSlot', () => {
mockWarn()
it('should render slot', () => {
let child
const vnode = renderSlot(

View File

@@ -12,11 +12,8 @@ import {
Comment,
VNode
} from '@vue/runtime-test'
import { mockWarn } from '@vue/shared'
describe('resolveAssets', () => {
mockWarn()
test('should work', () => {
const FooBar = () => null
const BarBaz = { mounted: () => null }

View File

@@ -1,9 +1,6 @@
import { toHandlers } from '../../src/helpers/toHandlers'
import { mockWarn } from '@vue/shared'
describe('toHandlers', () => {
mockWarn()
it('should not accept non-objects', () => {
toHandlers(null as any)
toHandlers(undefined as any)

View File

@@ -12,7 +12,6 @@ import {
defineComponent
} from '@vue/runtime-dom'
import { renderToString, SSRContext } from '@vue/server-renderer'
import { mockWarn } from '@vue/shared'
function mountWithHydration(html: string, render: () => any) {
const container = document.createElement('div')
@@ -34,8 +33,6 @@ const triggerEvent = (type: string, el: Element) => {
}
describe('SSR hydration', () => {
mockWarn()
beforeEach(() => {
document.body.innerHTML = ''
})

View File

@@ -13,11 +13,8 @@ import {
createCommentVNode,
Fragment
} from '@vue/runtime-dom'
import { mockWarn } from '@vue/shared'
describe('attribute fallthrough', () => {
mockWarn()
it('should allow attrs to fallthrough', async () => {
const click = jest.fn()
const childUpdated = jest.fn()

View File

@@ -8,10 +8,6 @@ import {
serialize,
serializeInner
} from '@vue/runtime-test'
import { mockWarn } from '@vue/shared'
mockWarn()
function toSpan(content: any) {
if (typeof content === 'string') {
return h('span', content.toString())

View File

@@ -11,14 +11,12 @@ import {
transformVNodeArgs
} from '../src/vnode'
import { Data } from '../src/component'
import { ShapeFlags, PatchFlags, mockWarn } from '@vue/shared'
import { ShapeFlags, PatchFlags } from '@vue/shared'
import { h, reactive, isReactive } from '../src'
import { createApp, nodeOps, serializeInner } from '@vue/runtime-test'
import { setCurrentRenderingInstance } from '../src/componentRenderUtils'
describe('vnode', () => {
mockWarn()
test('create with just tag', () => {
const vnode = createVNode('p')
expect(vnode.type).toBe('p')