-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: slot params missing double quote (#605)
* fix: slot params missing double quote * fix: exclude nodemodule test case
- Loading branch information
1 parent
91d3ae1
commit e651dff
Showing
6 changed files
with
220 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/vue-generator/test/testcases/sfc/case06/case06.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expect, test } from 'vitest' | ||
import { genSFCWithDefaultPlugin } from '@/generator/vue/sfc' | ||
import schema from './page.schema.json' | ||
import componentsMap from './components-map.json' | ||
import { formatCode } from '@/utils/formatCode' | ||
|
||
test('should generate slot declaration correctly', async () => { | ||
const res = genSFCWithDefaultPlugin(schema, componentsMap) | ||
const formattedCode = formatCode(res, 'vue') | ||
|
||
await expect(formattedCode).toMatchFileSnapshot('./expected/slotTest.vue') | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/vue-generator/test/testcases/sfc/case06/components-map.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"componentName": "TinyTree", | ||
"exportName": "Tree", | ||
"package": "@opentiny/vue", | ||
"version": "^3.10.0", | ||
"destructuring": true | ||
} | ||
] |
54 changes: 54 additions & 0 deletions
54
packages/vue-generator/test/testcases/sfc/case06/expected/slotTest.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<template> | ||
<div> | ||
<tiny-tree | ||
:data="[ | ||
{ label: '一级 1', children: [{ label: '二级 1-1', children: [{ label: '三级 1-1-1' }] }] }, | ||
{ | ||
label: '一级 2', | ||
children: [ | ||
{ label: '二级 2-1', children: [{ label: '三级 2-1-1' }] }, | ||
{ label: '二级 2-2', children: [{ label: '三级 2-2-1' }] } | ||
] | ||
} | ||
]" | ||
> | ||
<template #default="{ data }"> | ||
<span>{{ data.label }}</span></template | ||
></tiny-tree | ||
> | ||
<tiny-tree | ||
:data="[ | ||
{ label: '一级 1', children: [{ label: '二级 1-1', children: [{ label: '三级 1-1-1' }] }] }, | ||
{ | ||
label: '一级 2', | ||
children: [ | ||
{ label: '二级 2-1', children: [{ label: '三级 2-1-1' }] }, | ||
{ label: '二级 2-2', children: [{ label: '三级 2-2-1' }] } | ||
] | ||
} | ||
]" | ||
> | ||
<template #default="data"> | ||
<span>{{ data.label }}</span></template | ||
></tiny-tree | ||
> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { Tree as TinyTree } from '@opentiny/vue' | ||
import * as vue from 'vue' | ||
import { defineProps, defineEmits } from 'vue' | ||
import { I18nInjectionKey } from 'vue-i18n' | ||
const props = defineProps({}) | ||
const emit = defineEmits([]) | ||
const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode() | ||
const wrap = lowcodeWrap(props, { emit }) | ||
wrap({ stores }) | ||
const state = vue.reactive({}) | ||
wrap({ state }) | ||
</script> | ||
<style scoped></style> |
143 changes: 143 additions & 0 deletions
143
packages/vue-generator/test/testcases/sfc/case06/page.schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
{ | ||
"state": {}, | ||
"methods": {}, | ||
"componentName": "Page", | ||
"fileName": "createVm", | ||
"css": "", | ||
"props": {}, | ||
"lifeCycles": {}, | ||
"children": [ | ||
{ | ||
"componentName": "TinyTree", | ||
"props": { | ||
"data": [ | ||
{ | ||
"label": "一级 1", | ||
"children": [ | ||
{ | ||
"label": "二级 1-1", | ||
"children": [ | ||
{ | ||
"label": "三级 1-1-1" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "一级 2", | ||
"children": [ | ||
{ | ||
"label": "二级 2-1", | ||
"children": [ | ||
{ | ||
"label": "三级 2-1-1" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "二级 2-2", | ||
"children": [ | ||
{ | ||
"label": "三级 2-2-1" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"id": "33f52342", | ||
"children": [ | ||
{ | ||
"componentName": "Template", | ||
"props": { | ||
"slot": { | ||
"name": "default", | ||
"params": ["data"] | ||
} | ||
}, | ||
"children": [ | ||
{ | ||
"componentName": "Text", | ||
"props": { | ||
"text": { | ||
"type": "JSExpression", | ||
"value": "data.label" | ||
} | ||
}, | ||
"id": "c225d165" | ||
} | ||
], | ||
"id": "415d5f65" | ||
} | ||
] | ||
}, | ||
{ | ||
"componentName": "TinyTree", | ||
"props": { | ||
"data": [ | ||
{ | ||
"label": "一级 1", | ||
"children": [ | ||
{ | ||
"label": "二级 1-1", | ||
"children": [ | ||
{ | ||
"label": "三级 1-1-1" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "一级 2", | ||
"children": [ | ||
{ | ||
"label": "二级 2-1", | ||
"children": [ | ||
{ | ||
"label": "三级 2-1-1" | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "二级 2-2", | ||
"children": [ | ||
{ | ||
"label": "三级 2-2-1" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"id": "33f52342", | ||
"children": [ | ||
{ | ||
"componentName": "Template", | ||
"props": { | ||
"slot": { | ||
"name": "default", | ||
"params": "data" | ||
} | ||
}, | ||
"children": [ | ||
{ | ||
"componentName": "Text", | ||
"props": { | ||
"text": { | ||
"type": "JSExpression", | ||
"value": "data.label" | ||
} | ||
}, | ||
"id": "c225d165" | ||
} | ||
], | ||
"id": "415d5f65" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters