Skip to content

Commit 61b1ef5

Browse files
committed
chore: move the test file to the correct location
1 parent 7295919 commit 61b1ef5

13 files changed

+367
-308
lines changed

test/__snapshots__/dts.test.ts.snap renamed to packages/core/test/__snapshots__/dts.test.ts.snap

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`dts > components only 1`] = `
44
"/* eslint-disable */
55
/* prettier-ignore */
66
// @ts-nocheck
77
// Generated by vite-plugin-uni-components
88
// Read more: https://github.com/vuejs/core/pull/3399
9-
import '@vue/runtime-core'
10-
119
export {}
1210
1311
declare module 'vue' {
1412
export interface GlobalComponents {
15-
RouterLink: typeof import('vue-router')['RouterLink']
16-
RouterView: typeof import('vue-router')['RouterView']
1713
TestComp: typeof import('test/component/TestComp')['default']
1814
}
1915
}
@@ -26,8 +22,6 @@ exports[`dts > directive only 1`] = `
2622
// @ts-nocheck
2723
// Generated by vite-plugin-uni-components
2824
// Read more: https://github.com/vuejs/core/pull/3399
29-
import '@vue/runtime-core'
30-
3125
export {}
3226
3327
declare module 'vue' {
@@ -44,14 +38,10 @@ exports[`dts > getDeclaration 1`] = `
4438
// @ts-nocheck
4539
// Generated by vite-plugin-uni-components
4640
// Read more: https://github.com/vuejs/core/pull/3399
47-
import '@vue/runtime-core'
48-
4941
export {}
5042
5143
declare module 'vue' {
5244
export interface GlobalComponents {
53-
RouterLink: typeof import('vue-router')['RouterLink']
54-
RouterView: typeof import('vue-router')['RouterView']
5545
TestComp: typeof import('test/component/TestComp')['default']
5646
}
5747
export interface ComponentCustomProperties {
@@ -98,20 +88,32 @@ exports[`dts > parseDeclaration 1`] = `
9888
}
9989
`;
10090

101-
exports[`dts > writeDeclaration - keep unused 1`] = `
91+
exports[`dts > vue 2.7 components only 1`] = `
10292
"/* eslint-disable */
10393
/* prettier-ignore */
10494
// @ts-nocheck
10595
// Generated by vite-plugin-uni-components
10696
// Read more: https://github.com/vuejs/core/pull/3399
107-
import '@vue/runtime-core'
97+
export {}
98+
99+
declare module 'vue' {
100+
export interface GlobalComponents {
101+
TestComp: typeof import('test/component/TestComp')['default']
102+
}
103+
}
104+
"
105+
`;
108106

107+
exports[`dts > writeDeclaration - keep unused 1`] = `
108+
"/* eslint-disable */
109+
/* prettier-ignore */
110+
// @ts-nocheck
111+
// Generated by vite-plugin-uni-components
112+
// Read more: https://github.com/vuejs/core/pull/3399
109113
export {}
110114
111115
declare module 'vue' {
112116
export interface GlobalComponents {
113-
RouterLink: typeof import('vue-router')['RouterLink']
114-
RouterView: typeof import('vue-router')['RouterView']
115117
SomeComp: typeof import('test/component/SomeComp')['default']
116118
TestComp: typeof import('test/component/TestComp')['default']
117119
}
@@ -130,14 +132,10 @@ exports[`dts > writeDeclaration 1`] = `
130132
// @ts-nocheck
131133
// Generated by vite-plugin-uni-components
132134
// Read more: https://github.com/vuejs/core/pull/3399
133-
import '@vue/runtime-core'
134-
135135
export {}
136136
137137
declare module 'vue' {
138138
export interface GlobalComponents {
139-
RouterLink: typeof import('vue-router')['RouterLink']
140-
RouterView: typeof import('vue-router')['RouterView']
141139
TestComp: typeof import('test/component/TestComp')['default']
142140
}
143141
export interface ComponentCustomProperties {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`search > should with namespace & collapse 1`] = `[]`;
4+
5+
exports[`search > should with namespace 1`] = `[]`;
6+
7+
exports[`search > should work 1`] = `[]`;

test/__snapshots__/stringifyComponentImport.test.ts.snap renamed to packages/core/test/__snapshots__/stringifyComponentImport.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Vitest Snapshot v1
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`stringifyComponentImport > importName 1`] = `"import { a as Test } from 'test'"`;
3+
exports[`stringifyComponentImport > importName 1`] = `"import Test from 'test'"`;
44

55
exports[`stringifyComponentImport > multiple sideEffects 1`] = `"import Test from 'test';import 'test.css';import css from 'test2.css'"`;
66

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`component and directive as same name > vue2 transform should work 1`] = `
4+
{
5+
"code": "/* vite-plugin-uni-components disabled */import __unplugin_directives_0 from 'test/directive/Loading';
6+
import __unplugin_components_0 from 'test/component/Loading';
7+
8+
var render = function () {
9+
this.$options.directives[\\"loading\\"] = __unplugin_directives_0;
10+
var _vm = this
11+
var _h = _vm.$createElement
12+
var _c = _vm._self._c || _h
13+
return _c(__unplugin_components_0, {
14+
directives: [
15+
{ name: \\"loading\\", rawName: \\"v-loading\\", value: 123, expression: \\"123\\" }
16+
]
17+
})
18+
}
19+
var staticRenderFns = []
20+
render._withStripped = true
21+
export { render, staticRenderFns }
22+
",
23+
}
24+
`;
25+
26+
exports[`component and directive as same name > vue2.7 transform should work 1`] = `
27+
{
28+
"code": "/* vite-plugin-uni-components disabled */import __unplugin_directives_0 from 'test/directive/Loading';
29+
import __unplugin_components_0 from 'test/component/Div';
30+
31+
import { defineComponent as _defineComponent } from \\"vue\\";
32+
const _sfc_main = /* @__PURE__ */ _defineComponent({
33+
__name: \\"App\\",
34+
setup(__props) {
35+
return { __sfc: true };
36+
}
37+
});
38+
var _sfc_render = function render() {
39+
this.$options.directives[\\"loading\\"] = __unplugin_directives_0;
40+
var _vm = this, _c = _vm._self._c, _setup = _vm._self._setupProxy;
41+
return _c(__unplugin_components_0, { directives: [{ name: \\"loading\\", rawName: \\"v-loading\\", value: 123, expression: \\"123\\" }] }, [], 1);
42+
};
43+
",
44+
}
45+
`;
46+
47+
exports[`component and directive as same name > vue3 transform should work 1`] = `
48+
{
49+
"code": "/* vite-plugin-uni-components disabled */import __unplugin_directives_0 from 'test/directive/ElInfiniteScroll';
50+
import __unplugin_components_0 from 'test/component/ElInfiniteScroll';
51+
52+
const render = (_ctx, _cache) => {
53+
const _component_el_infinite_scroll = __unplugin_components_0
54+
const _directive_el_infinite_scroll = __unplugin_directives_0
55+
56+
return _withDirectives(
57+
(_openBlock(),
58+
_createBlock(_component_test_comp, null, null, 512 /* NEED_PATCH */)),
59+
[[_directive_loading, 123]]
60+
)
61+
}
62+
",
63+
}
64+
`;
65+
66+
exports[`transform > vue2 transform should work 1`] = `
67+
{
68+
"code": "/* vite-plugin-uni-components disabled */import __unplugin_directives_0 from 'test/directive/Loading';
69+
import __unplugin_components_0 from 'test/component/TestComp';
70+
71+
var render = function () {
72+
this.$options.directives[\\"loading\\"] = __unplugin_directives_0;
73+
var _vm = this
74+
var _h = _vm.$createElement
75+
var _c = _vm._self._c || _h
76+
return _c(__unplugin_components_0, {
77+
directives: [
78+
{ name: \\"loading\\", rawName: \\"v-loading\\", value: 123, expression: \\"123\\" }
79+
]
80+
})
81+
}
82+
var staticRenderFns = []
83+
render._withStripped = true
84+
export { render, staticRenderFns }
85+
",
86+
}
87+
`;
88+
89+
exports[`transform > vue2 transform with jsx should work 1`] = `
90+
{
91+
"code": "/* vite-plugin-uni-components disabled */import __unplugin_components_0 from 'test/component/TestComp';
92+
93+
export default {
94+
render(){
95+
return h(__unplugin_components_0, {
96+
directives: [
97+
{ name: \\"loading\\", rawName: \\"v-loading\\", value: 123, expression: \\"123\\" }
98+
]
99+
})
100+
}
101+
}
102+
",
103+
}
104+
`;
105+
106+
exports[`transform > vue3 transform should work 1`] = `
107+
{
108+
"code": "/* vite-plugin-uni-components disabled */import __unplugin_directives_0 from 'test/directive/Loading';
109+
import __unplugin_components_0 from 'test/component/TestComp';
110+
111+
const render = (_ctx, _cache) => {
112+
const _component_test_comp = __unplugin_components_0
113+
const _directive_loading = __unplugin_directives_0
114+
115+
return _withDirectives(
116+
(_openBlock(),
117+
_createBlock(_component_test_comp, null, null, 512 /* NEED_PATCH */)),
118+
[[_directive_loading, 123]]
119+
)
120+
}
121+
",
122+
}
123+
`;

test/dts.test.ts renamed to packages/core/test/dts.test.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { readFile, writeFile } from 'fs/promises'
2-
import path from 'path'
3-
import { describe, expect, test } from 'vitest'
1+
import { readFile, writeFile } from 'node:fs/promises'
2+
import path from 'node:path'
3+
import { describe, expect, it } from 'vitest'
44
import type { ComponentResolver } from '../src'
55
import { Context } from '../src/context'
66
import { getDeclaration, parseDeclaration } from '../src/declaration'
@@ -17,7 +17,7 @@ const resolver: ComponentResolver[] = [
1717
]
1818

1919
describe('dts', () => {
20-
test('getDeclaration', async () => {
20+
it('getDeclaration', async () => {
2121
const ctx = new Context({
2222
resolvers: resolver,
2323
directives: true,
@@ -31,7 +31,7 @@ const _directive_loading = _resolveDirective("loading")`
3131
expect(declarations).toMatchSnapshot()
3232
})
3333

34-
test('writeDeclaration', async () => {
34+
it('writeDeclaration', async () => {
3535
const filepath = path.resolve(__dirname, 'tmp/dts-test.d.ts')
3636
const ctx = new Context({
3737
resolvers: resolver,
@@ -47,7 +47,7 @@ const _directive_loading = _resolveDirective("loading")`
4747
expect(await readFile(filepath, 'utf-8')).matchSnapshot()
4848
})
4949

50-
test('writeDeclaration - keep unused', async () => {
50+
it('writeDeclaration - keep unused', async () => {
5151
const filepath = path.resolve(__dirname, 'tmp/dts-keep-unused.d.ts')
5252
await writeFile(
5353
filepath,
@@ -83,7 +83,7 @@ const _directive_loading = _resolveDirective("loading")`
8383
expect(contents).toContain('vSome')
8484
})
8585

86-
test('components only', async () => {
86+
it('components only', async () => {
8787
const ctx = new Context({
8888
resolvers: resolver,
8989
directives: true,
@@ -95,7 +95,7 @@ const _directive_loading = _resolveDirective("loading")`
9595
expect(declarations).toMatchSnapshot()
9696
})
9797

98-
test('vue 2.7 components only', async () => {
98+
it('vue 2.7 components only', async () => {
9999
const ctx = new Context({
100100
resolvers: resolver,
101101
directives: true,
@@ -108,7 +108,7 @@ const _directive_loading = _resolveDirective("loading")`
108108
expect(declarations).toMatchSnapshot()
109109
})
110110

111-
test('directive only', async () => {
111+
it('directive only', async () => {
112112
const ctx = new Context({
113113
resolvers: resolver,
114114
directives: true,
@@ -121,17 +121,15 @@ const _directive_loading = _resolveDirective("loading")`
121121
expect(declarations).toMatchSnapshot()
122122
})
123123

124-
test('parseDeclaration', async () => {
124+
it('parseDeclaration', async () => {
125125
const code = `
126126
/* eslint-disable */
127-
/* prettier-ignore */
128127
// generated by unplugin-vue-components
129128
// We suggest you to commit this file into source control
130129
// Read more: https://github.com/vuejs/core/pull/3399
131-
import '@vue/runtime-core'
132-
133130
export {}
134131
132+
/* prettier-ignore */
135133
declare module 'vue' {
136134
export interface GlobalComponents {
137135
ComponentA: typeof import('./src/components/ComponentA.vue')['default']
@@ -144,17 +142,15 @@ declare module 'vue' {
144142
expect(imports).matchSnapshot()
145143
})
146144

147-
test('parseDeclaration - has icon component like <IMdi:diceD12>', async () => {
145+
it('parseDeclaration - has icon component like <IMdi:diceD12>', async () => {
148146
const code = `
149147
/* eslint-disable */
150-
/* prettier-ignore */
151148
// generated by unplugin-vue-components
152149
// We suggest you to commit this file into source control
153150
// Read more: https://github.com/vuejs/core/pull/3399
154-
import '@vue/runtime-core'
155-
156151
export {}
157152
153+
/* prettier-ignore */
158154
declare module 'vue' {
159155
export interface GlobalComponents {
160156
ComponentA: typeof import('./src/components/ComponentA.vue')['default']
@@ -167,17 +163,15 @@ declare module 'vue' {
167163
expect(imports).matchSnapshot()
168164
})
169165

170-
test('parseDeclaration - with directives', async () => {
166+
it('parseDeclaration - with directives', async () => {
171167
const code = `
172168
/* eslint-disable */
173-
/* prettier-ignore */
174169
// generated by unplugin-vue-components
175170
// We suggest you to commit this file into source control
176171
// Read more: https://github.com/vuejs/core/pull/3399
177-
import '@vue/runtime-core'
178-
179172
export {}
180173
174+
/* prettier-ignore */
181175
declare module 'vue' {
182176
export interface GlobalComponents {
183177
ComponentA: typeof import('./src/components/ComponentA.vue')['default']

0 commit comments

Comments
 (0)