refactor(createComponent): rename to defineComponent (#549)

This commit is contained in:
Chris Fritz
2019-12-22 10:58:12 -05:00
committed by Evan You
parent 7d2ae08277
commit 1c4cdd841d
18 changed files with 74 additions and 74 deletions

View File

@@ -8,13 +8,13 @@ import {
nextTick,
renderToString,
ref,
createComponent,
defineComponent,
mockWarn
} from '@vue/runtime-test'
describe('api: options', () => {
test('data', async () => {
const Comp = createComponent({
const Comp = defineComponent({
data() {
return {
foo: 1
@@ -42,7 +42,7 @@ describe('api: options', () => {
})
test('computed', async () => {
const Comp = createComponent({
const Comp = defineComponent({
data() {
return {
foo: 1
@@ -78,7 +78,7 @@ describe('api: options', () => {
})
test('methods', async () => {
const Comp = createComponent({
const Comp = defineComponent({
data() {
return {
foo: 1
@@ -536,7 +536,7 @@ describe('api: options', () => {
})
test('accessing setup() state from options', async () => {
const Comp = createComponent({
const Comp = defineComponent({
setup() {
return {
count: ref(0)

View File

@@ -7,7 +7,7 @@ import {
serializeInner,
nextTick,
watch,
createComponent,
defineComponent,
triggerEvent,
TestElement
} from '@vue/runtime-test'
@@ -16,7 +16,7 @@ import {
describe('api: setup context', () => {
it('should expose return values to template render context', () => {
const Comp = createComponent({
const Comp = defineComponent({
setup() {
return {
// ref should auto-unwrap
@@ -53,7 +53,7 @@ describe('api: setup context', () => {
render: () => h(Child, { count: count.value })
}
const Child = createComponent({
const Child = defineComponent({
setup(props: { count: number }) {
watch(() => {
dummy = props.count
@@ -82,7 +82,7 @@ describe('api: setup context', () => {
render: () => h(Child, { count: count.value })
}
const Child = createComponent({
const Child = defineComponent({
props: {
count: Number
},
@@ -177,7 +177,7 @@ describe('api: setup context', () => {
})
}
const Child = createComponent({
const Child = defineComponent({
props: {
count: {
type: Number,

View File

@@ -5,7 +5,7 @@ import {
render,
nextTick,
Ref,
createComponent
defineComponent
} from '@vue/runtime-test'
// reference: https://vue-composition-api-rfc.netlify.com/api.html#template-refs
@@ -83,7 +83,7 @@ describe('api: template refs', () => {
const root = nodeOps.createElement('div')
const fn = jest.fn()
const Comp = createComponent(() => () => h('div', { ref: fn }))
const Comp = defineComponent(() => () => h('div', { ref: fn }))
render(h(Comp), root)
expect(fn.mock.calls[0][0]).toBe(root.children[0])
})
@@ -94,7 +94,7 @@ describe('api: template refs', () => {
const fn2 = jest.fn()
const fn = ref(fn1)
const Comp = createComponent(() => () => h('div', { ref: fn.value }))
const Comp = defineComponent(() => () => h('div', { ref: fn.value }))
render(h(Comp), root)
expect(fn1.mock.calls).toHaveLength(1)
@@ -113,7 +113,7 @@ describe('api: template refs', () => {
const fn = jest.fn()
const toggle = ref(true)
const Comp = createComponent(() => () =>
const Comp = defineComponent(() => () =>
toggle.value ? h('div', { ref: fn }) : null
)
render(h(Comp), root)

View File

@@ -8,7 +8,7 @@ import {
ref,
nextTick,
mockWarn,
createComponent
defineComponent
} from '@vue/runtime-test'
import { setErrorRecovery } from '../src/errorHandling'
@@ -235,7 +235,7 @@ describe('error handling', () => {
}
}
const Child = createComponent(() => () => h('div', { ref }))
const Child = defineComponent(() => () => h('div', { ref }))
render(h(Comp), nodeOps.createElement('div'))
expect(fn).toHaveBeenCalledWith(err, 'ref function')

View File

@@ -6,7 +6,7 @@ import {
mergeProps,
ref,
onUpdated,
createComponent
defineComponent
} from '@vue/runtime-dom'
import { mockWarn } from '@vue/runtime-test'
@@ -102,7 +102,7 @@ describe('attribute fallthrough', () => {
}
}
const Child = createComponent({
const Child = defineComponent({
props: {
foo: Number
},
@@ -179,7 +179,7 @@ describe('attribute fallthrough', () => {
}
}
const GrandChild = createComponent({
const GrandChild = defineComponent({
props: {
foo: Number
},
@@ -232,7 +232,7 @@ describe('attribute fallthrough', () => {
}
}
const Child = createComponent({
const Child = defineComponent({
props: ['foo'],
inheritAttrs: false,
render() {
@@ -255,7 +255,7 @@ describe('attribute fallthrough', () => {
}
}
const Child = createComponent({
const Child = defineComponent({
props: ['foo'],
inheritAttrs: false,
render() {
@@ -287,7 +287,7 @@ describe('attribute fallthrough', () => {
}
}
const Child = createComponent({
const Child = defineComponent({
props: ['foo'],
render() {
return [h('div'), h('div')]
@@ -308,7 +308,7 @@ describe('attribute fallthrough', () => {
}
}
const Child = createComponent({
const Child = defineComponent({
props: ['foo'],
render() {
return [h('div'), h('div', this.$attrs)]

View File

@@ -3,7 +3,7 @@ import {
serializeInner,
render,
h,
createComponent,
defineComponent,
Portal,
Text,
Fragment,
@@ -19,7 +19,7 @@ describe('renderer: portal', () => {
const target = nodeOps.createElement('div')
const root = nodeOps.createElement('div')
const Comp = createComponent(() => () =>
const Comp = defineComponent(() => () =>
h(Fragment, [
h(Portal, { target }, h('div', 'teleported')),
h('div', 'root')
@@ -37,7 +37,7 @@ describe('renderer: portal', () => {
const target = ref(targetA)
const root = nodeOps.createElement('div')
const Comp = createComponent(() => () =>
const Comp = defineComponent(() => () =>
h(Fragment, [
h(Portal, { target: target.value }, h('div', 'teleported')),
h('div', 'root')
@@ -64,7 +64,7 @@ describe('renderer: portal', () => {
h('div', 'teleported')
])
const Comp = createComponent(() => () =>
const Comp = defineComponent(() => () =>
h(Portal, { target }, children.value)
)
render(h(Comp), root)