forked from UnrefinedBrain/vue-upgrade-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonReady.spec.ts
More file actions
37 lines (33 loc) · 860 Bytes
/
onReady.spec.ts
File metadata and controls
37 lines (33 loc) · 860 Bytes
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
import { it, expect } from 'vitest';
import { transform } from 'vue-metamorph';
import { onReadyPlugin } from './onReady';
it('should rewrite router.onReady with 1 argument', () => {
const input = `
router.onReady(() => {
console.log('router ready');
});
`;
expect(transform(input, 'file.js', [onReadyPlugin]).code).toMatchInlineSnapshot(`
"router.isReady().then(() => {
console.log('router ready');
});
"
`);
});
it('should rewrite router.onReady with 2 arguments', () => {
const input = `
router.onReady(() => {
console.log('router ready');
}, () => {
console.log('router error');
});
`;
expect(transform(input, 'file.js', [onReadyPlugin]).code).toMatchInlineSnapshot(`
"router.isReady().then(() => {
console.log('router ready');
}).catch(() => {
console.log('router error');
});
"
`);
});