Skip to content

Commit 68138c4

Browse files
committed
test(vue): add tests for async components
1 parent 788089e commit 68138c4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<h1>Goodbye {{ name }}</h1>
3+
</template>

src/Vue/Resources/assets/test/register_controller.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@
1212
import {registerVueControllerComponents} from '../src/register_controller';
1313
import {createRequireContextPolyfill} from './util/require_context_poylfill';
1414
import Hello from './fixtures/Hello.vue'
15+
import Goodbye from './fixtures-lazy/Goodbye.vue'
1516

1617
require.context = createRequireContextPolyfill(__dirname);
1718

1819
describe('registerVueControllerComponents', () => {
19-
it('test', () => {
20+
it('test should resolve components synchronously', () => {
2021
registerVueControllerComponents(require.context('./fixtures', true, /\.vue$/));
2122
const resolveComponent = window.resolveVueComponent;
2223

2324
expect(resolveComponent).not.toBeUndefined();
2425
expect(resolveComponent('Hello')).toBe(Hello);
2526
});
27+
28+
it('test should resolve lazy components asynchronously', () => {
29+
registerVueControllerComponents(require.context('./fixtures-lazy', true, /\.vue$/, 'lazy'));
30+
const resolveComponent = window.resolveVueComponent;
31+
32+
expect(resolveComponent).not.toBeUndefined();
33+
expect(resolveComponent('Goodbye')).toBe(Goodbye);
34+
});
2635
});

0 commit comments

Comments
 (0)