Skip to content

Commit d6277b1

Browse files
author
RicardoErii
committed
test(compile-sfc): modify test cases
1 parent a82a56e commit d6277b1

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineModel.spec.ts.snap

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,20 @@ return { modelValue, c, toString }
2323
}"
2424
`;
2525

26-
exports[`defineModel() > w/ Boolean And Function types, production mode 1`] = `
26+
exports[`defineModel() > w/ Boolean types, production mode 1`] = `
2727
"import { useModel as _useModel, defineComponent as _defineComponent } from 'vue'
2828
2929
export default /*#__PURE__*/_defineComponent({
3030
props: {
31-
\\"modelValue\\": { type: [Boolean, String] },
32-
\\"fn\\": {},
33-
\\"fnWithDefault\\": { type: Function, ...{ default: () => null } },
34-
\\"optional\\": { required: false },
31+
\\"modelValue\\": { type: [Boolean, String, Number] },
3532
},
36-
emits: [\\"update:modelValue\\", \\"update:fn\\", \\"update:fnWithDefault\\", \\"update:optional\\"],
33+
emits: [\\"update:modelValue\\"],
3734
setup(__props, { expose: __expose }) {
3835
__expose();
3936
4037
const modelValue = _useModel(__props, \\"modelValue\\")
41-
const fn = _useModel(__props, \\"fn\\")
42-
const fnWithDefault = _useModel(__props, \\"fnWithDefault\\")
43-
const optional = _useModel(__props, \\"optional\\")
4438
45-
return { modelValue, fn, fnWithDefault, optional }
39+
return { modelValue }
4640
}
4741
4842
})"

packages/compiler-sfc/__tests__/compileScript/defineModel.spec.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -182,37 +182,23 @@ describe('defineModel()', () => {
182182
})
183183
})
184184

185-
test('w/ Boolean And Function types, production mode', () => {
185+
test('w/ Boolean types, production mode', () => {
186186
const { content, bindings } = compile(
187187
`
188188
<script setup lang="ts">
189-
const modelValue = defineModel<boolean | string>()
190-
const fn = defineModel<() => void>('fn')
191-
const fnWithDefault = defineModel<() => void>('fnWithDefault', { default: () => null })
192-
const optional = defineModel<string>('optional', { required: false })
189+
const modelValue = defineModel<boolean | string | number>()
193190
</script>
194191
`,
195192
{ defineModel: true, isProd: true }
196193
)
197194
assertCode(content)
198-
expect(content).toMatch('"modelValue": { type: [Boolean, String] }')
199-
expect(content).toMatch('"fn": {}')
200-
expect(content).toMatch(
201-
'"fnWithDefault": { type: Function, ...{ default: () => null } },'
202-
)
203-
expect(content).toMatch('"optional": { required: false }')
204-
expect(content).toMatch(
205-
'emits: ["update:modelValue", "update:fn", "update:fnWithDefault", "update:optional"]'
206-
)
195+
expect(content).toMatch('"modelValue": { type: [Boolean, String, Number] }')
196+
expect(content).toMatch('emits: ["update:modelValue"]')
207197
expect(content).toMatch(
208198
`const modelValue = _useModel(__props, "modelValue")`
209199
)
210-
expect(content).toMatch(`const fn = _useModel(__props, "fn")`)
211200
expect(bindings).toStrictEqual({
212-
modelValue: BindingTypes.SETUP_REF,
213-
fn: BindingTypes.SETUP_REF,
214-
fnWithDefault: BindingTypes.SETUP_REF,
215-
optional: BindingTypes.SETUP_REF
201+
modelValue: BindingTypes.SETUP_REF
216202
})
217203
})
218204
})

0 commit comments

Comments
 (0)