summaryrefslogtreecommitdiff
path: root/spec/frontend/vue3migration/compiler_spec.js
blob: 3623f69fe07b2b82eaf744e3cfbc71c11a4a22f1 (plain)
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
import { mount } from '@vue/test-utils';

import SlotsWithSameName from './components/slots_with_same_name.vue';
import VOnceInsideVIf from './components/v_once_inside_v_if.vue';
import KeyInsideTemplate from './components/key_inside_template.vue';
import CommentsOnRootLevel from './components/comments_on_root_level.vue';
import SlotWithComment from './components/slot_with_comment.vue';
import DefaultSlotWithComment from './components/default_slot_with_comment.vue';

describe('Vue.js 3 compiler edge cases', () => {
  it('workarounds issue #6063 when same slot is used with whitespace preserve', () => {
    expect(() => mount(SlotsWithSameName)).not.toThrow();
  });

  it('workarounds issue #7725 when v-once is used inside v-if', () => {
    expect(() => mount(VOnceInsideVIf)).not.toThrow();
  });

  it('renders vue.js 2 component when key is inside template', () => {
    const wrapper = mount(KeyInsideTemplate);
    expect(wrapper.text()).toBe('12345');
  });

  it('passes attributes to component with trailing comments on root level', () => {
    const wrapper = mount(CommentsOnRootLevel, { propsData: { 'data-testid': 'test' } });
    expect(wrapper.html()).toBe('<div data-testid="test"></div>');
  });

  it('treats empty slots with comments as empty', () => {
    const wrapper = mount(SlotWithComment);
    expect(wrapper.html()).toBe('<div>Simple</div>');
  });

  it('treats empty default slot with comments as empty', () => {
    const wrapper = mount(DefaultSlotWithComment);
    expect(wrapper.html()).toBe('<div>Simple</div>');
  });
});