/
children.spec.ts
62 lines (59 loc) · 1.44 KB
/
children.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { it, expect } from 'vitest';
import { findManualMigrations } from 'vue-metamorph';
import { childrenPlugin } from './children';
it('should report on $children usage', () => {
const input = `
<template>
<div>
{{ !!$children[0] }}
</div>
</template>
<script>
export default {
created() {
console.log(this.$children[0]);
},
}
</script>
`;
expect(findManualMigrations(input, 'file.vue', [childrenPlugin])).toMatchInlineSnapshot(`
[
{
"columnEnd": 30,
"columnStart": 22,
"file": "file.vue",
"lineEnd": 11,
"lineStart": 11,
"message": "$children has been removed.
See: https://v3-migration.vuejs.org/breaking-changes/children.html#children",
"pluginName": "children",
"snippet": " 8 | <script>
9 | export default {
10 | created() {
11 | console.log(this.$children[0]);
| ^^^^^^^^^
12 | },
13 | }
14 | </script>",
},
{
"columnEnd": 18,
"columnStart": 10,
"file": "file.vue",
"lineEnd": 4,
"lineStart": 4,
"message": "$children has been removed.
See: https://v3-migration.vuejs.org/breaking-changes/children.html#children",
"pluginName": "children",
"snippet": "1 |
2 | <template>
3 | <div>
4 | {{ !!$children[0] }}
| ^^^^^^^^^
5 | </div>
6 | </template>
7 | ",
},
]
`);
});