Skip to content

Commit

Permalink
test: add
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Nov 1, 2022
1 parent db608b5 commit 6e558a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Expand Up @@ -1723,12 +1723,14 @@ export default /*#__PURE__*/_defineComponent({
foo: { type: String, required: false, default: 'hi' },
bar: { type: Number, required: false },
baz: { type: Boolean, required: true },
qux: { type: Function, required: false, default() { return 1 } }
qux: { type: Function, required: false, default() { return 1 } },
quux: { type: Promise, required: false, async default() { return await Promise.resolve('hi') } },
fred: { type: String, required: false, get default() { return 'fred' } }
},
setup(__props: any, { expose }) {
expose();

const props = __props as { foo: string, bar?: number, baz: boolean, qux(): number }
const props = __props as { foo: string, bar?: number, baz: boolean, qux(): number, quux: Promise<string>, fred: string }



Expand Down
18 changes: 15 additions & 3 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Expand Up @@ -975,10 +975,14 @@ const emit = defineEmits(['a', 'b'])
foo?: string
bar?: number;
baz: boolean;
qux?(): number
qux?(): number;
quux?: Promise<string>;
fred?: string
}>(), {
foo: 'hi',
qux() { return 1 }
qux() { return 1 },
async quux() { return await Promise.resolve('hi') },
get fred() { return 'fred' }
})
</script>
`)
Expand All @@ -992,14 +996,22 @@ const emit = defineEmits(['a', 'b'])
`qux: { type: Function, required: false, default() { return 1 } }`
)
expect(content).toMatch(
`{ foo: string, bar?: number, baz: boolean, qux(): number }`
`quux: { type: Promise, required: false, async default() { return await Promise.resolve('hi') } }`
)
expect(content).toMatch(
`fred: { type: String, required: false, get default() { return 'fred' } }`
)
expect(content).toMatch(
`{ foo: string, bar?: number, baz: boolean, qux(): number, quux: Promise<string>, fred: string }`
)
expect(content).toMatch(`const props = __props`)
expect(bindings).toStrictEqual({
foo: BindingTypes.PROPS,
bar: BindingTypes.PROPS,
baz: BindingTypes.PROPS,
qux: BindingTypes.PROPS,
quux: BindingTypes.PROPS,
fred: BindingTypes.PROPS,
props: BindingTypes.SETUP_CONST
})
})
Expand Down

0 comments on commit 6e558a1

Please sign in to comment.