Skip to content

Commit c86002f

Browse files
authored
+ Minor update. (#7)
- Add prop merging testing. - Add jsx-dev-runtime.js.
1 parent 0743778 commit c86002f

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

jsx-dev-runtime.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const jsxRuntime = require('./dist/jsx-runtime')
2+
module.exports = jsxRuntime

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dist/",
77
"jsx-runtime.js",
88
"jsx-runtime.mjs",
9+
"jsx-dev-runtime.js",
910
"README.md"
1011
],
1112
"main": "jsx-runtime.js",

test/prop-merging.spec.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* eslint-disable no-undef */
2+
3+
import { defineComponent, PropType } from '@vue/composition-api'
4+
import { shallowMount } from '@vue/test-utils'
5+
6+
describe('Prop merging test.', () => {
7+
it('Merge props should work properly.', () => {
8+
const Example = defineComponent({
9+
props: {
10+
name: String as PropType<string>,
11+
age: Number as PropType<number>
12+
},
13+
setup (props) {
14+
return () => (
15+
<div>Name: {props.name}, age: {props.age}</div>
16+
)
17+
}
18+
})
19+
20+
const wrapper = shallowMount(defineComponent({
21+
setup () {
22+
const props = {
23+
name: 'John Smith',
24+
age: 100
25+
}
26+
27+
return () => (
28+
<Example { ...props } />
29+
)
30+
}
31+
}))
32+
33+
expect(wrapper.html()).toBe('<div>Name: John Smith, age: 100</div>')
34+
})
35+
36+
it('Merge props should work properly.', () => {
37+
const Example = defineComponent({
38+
props: {
39+
name: String as PropType<string>,
40+
age: Number as PropType<number>,
41+
gender: String as PropType<string>
42+
},
43+
setup (props) {
44+
return () => (
45+
<div>Name: {props.name}, age: {props.age}, gender: {props.gender}</div>
46+
)
47+
}
48+
})
49+
50+
const wrapper = shallowMount(defineComponent({
51+
setup () {
52+
const props = {
53+
name: 'John Smith',
54+
age: 100
55+
}
56+
57+
return () => (
58+
<Example { ...props } gender='male' />
59+
)
60+
}
61+
}))
62+
63+
expect(wrapper.html()).toBe('<div>Name: John Smith, age: 100, gender: male</div>')
64+
})
65+
})

0 commit comments

Comments
 (0)