Skip to content

Commit 77940ba

Browse files
committed
test: add element-plus resolver
1 parent f55121a commit 77940ba

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Element Plus Resolver components and directives should be transformed 1`] = `
4+
Object {
5+
"code": "/* unplugin-vue-components disabled */import { ElButton as __unplugin_components_0 } from 'element-plus/es';import 'element-plus/es/components/button/style/css';
6+
7+
(_ctx, _cache) => {
8+
const _component_el_button = __unplugin_components_0
9+
const _directive_loading = _resolveDirective(\\"loading\\")
10+
11+
return (_openBlock(), _createElementBlock(_Fragment, null, [
12+
_createVNode(_component_el_button, null, {
13+
default: _withCtx(() => [
14+
_hoisted_1
15+
]),
16+
_: 1 /* STABLE */
17+
}),
18+
_withDirectives(_createElementVNode(\\"div\\", null, null, 512 /* NEED_PATCH */), [
19+
[_directive_loading, true]
20+
])
21+
], 64 /* STABLE_FRAGMENT */))
22+
}
23+
",
24+
}
25+
`;

test/resolvers/element-plus.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { ElementPlusResolver } from '../../src/resolvers'
2+
import { Context } from '../../src/core/context'
3+
4+
describe('Element Plus Resolver', () => {
5+
it('components and directives should be transformed', async() => {
6+
const code = `
7+
(_ctx, _cache) => {
8+
const _component_el_button = _resolveComponent("el-button")
9+
const _directive_loading = _resolveDirective("loading")
10+
11+
return (_openBlock(), _createElementBlock(_Fragment, null, [
12+
_createVNode(_component_el_button, null, {
13+
default: _withCtx(() => [
14+
_hoisted_1
15+
]),
16+
_: 1 /* STABLE */
17+
}),
18+
_withDirectives(_createElementVNode("div", null, null, 512 /* NEED_PATCH */), [
19+
[_directive_loading, true]
20+
])
21+
], 64 /* STABLE_FRAGMENT */))
22+
}
23+
`
24+
25+
const ctx = new Context({
26+
resolvers: [ElementPlusResolver({})],
27+
transformer: 'vue3',
28+
directives: true,
29+
})
30+
ctx.sourcemap = false
31+
expect(await ctx.transform(code, '')).toMatchSnapshot()
32+
})
33+
})

0 commit comments

Comments
 (0)