How to use the @vue/test-utils.createWrapper function in @vue/test-utils

To help you get started, we’ve selected a few @vue/test-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bootstrap-vue / bootstrap-vue / src / components / modal / helpers / bv-modal.spec.js View on Github external
})
    expect(p).toBeDefined()
    expect(p).toBeInstanceOf(Promise)

    await waitNT(wrapper.vm)
    await waitRAF()
    await waitNT(wrapper.vm)
    await waitRAF()
    await waitNT(wrapper.vm)
    await waitRAF()

    // Find the modal
    const modal = document.querySelector('#test2')
    expect(modal).toBeDefined()
    expect(modal).not.toEqual(null)
    const $modal = createWrapper(modal)
    expect($modal.is('div')).toBe(true)

    // Find the OK button and click it
    expect($modal.findAll('button').length).toBe(1)
    const $button = $modal.find('button')
    expect($button.text()).toEqual('OK')
    $button.trigger('click')

    // Promise should now resolve
    const result = await p
    expect(result).toEqual(true)

    await waitNT(wrapper.vm)
    await waitRAF()
    await waitNT(wrapper.vm)
    await waitRAF()
github bootstrap-vue / bootstrap-vue / src / components / toast / helpers / bv-toast.spec.js View on Github external
title: 'title',
      noAutoHide: true
    })

    await waitNT(wrapper.vm)
    await waitRAF()
    await waitNT(wrapper.vm)
    await waitRAF()
    await waitNT(wrapper.vm)
    await waitRAF()

    // Find the toast
    const toast = document.querySelector('#test2')
    expect(toast).toBeDefined()
    expect(toast).not.toEqual(null)
    const $toast = createWrapper(toast)
    expect($toast.is('div')).toBe(true)

    // Find  header
    expect($toast.find('.toast-header').exists()).toBe(true)
    expect($toast.find('.toast-header').text()).toContain('title')

    // Find body
    expect($toast.find('.toast-body').exists()).toBe(true)
    expect($toast.find('.toast-body').text()).toContain('message')

    // Find the Close button and click it
    expect($toast.findAll('button').length).toBe(1)
    const $button = $toast.find('button')
    expect($button.classes()).toContain('close')
    $button.trigger('click')
github bootstrap-vue / bootstrap-vue / src / components / collapse / collapse.spec.js View on Github external
const wrapper = mount(BCollapse, {
      attachToDocument: true,
      propsData: {
        // 'id' is a required prop
        id: 'test',
        visible: true
      },
      slots: {
        default: '<div>foobar</div>'
      },
      stubs: {
        // Disable use of default test transitionStub component
        transition: false
      }
    })
    const rootWrapper = createWrapper(wrapper.vm.$root)
    await waitNT(wrapper.vm)
    await waitRAF()
    expect(wrapper.emitted('show')).not.toBeDefined() // Does not emit show when initially visible
    expect(wrapper.emitted('input')).toBeDefined()
    expect(wrapper.emitted('input').length).toBe(1)
    expect(wrapper.emitted('input')[0][0]).toBe(true)
    expect(rootWrapper.emitted(EVENT_ACCORDION)).not.toBeDefined()
    expect(rootWrapper.emitted(EVENT_STATE)).toBeDefined()
    expect(rootWrapper.emitted(EVENT_STATE).length).toBe(1)
    expect(rootWrapper.emitted(EVENT_STATE)[0][0]).toBe('test') // ID
    expect(rootWrapper.emitted(EVENT_STATE)[0][1]).toBe(true) // Visible state
    expect(wrapper.element.style.display).toEqual('')

    wrapper.destroy()
  })
github gitlabhq / gitlabhq / spec / javascripts / notes / components / note_actions_spec.js View on Github external
it('closes tooltip when dropdown opens', done => {
        wrapper.find('.more-actions-toggle').trigger('click');

        const rootWrapper = createWrapper(wrapper.vm.$root);
        Vue.nextTick()
          .then(() => {
            const emitted = Object.keys(rootWrapper.emitted());

            expect(emitted).toEqual(['bv::hide::tooltip']);
            done();
          })
          .catch(done.fail);
      });
    });
github gitlabhq / gitlabhq / spec / frontend / notes / components / note_actions_spec.js View on Github external
it('closes tooltip when dropdown opens', (done) => {
        wrapper.find('.more-actions-toggle').trigger('click');

        const rootWrapper = createWrapper(wrapper.vm.$root);
        Vue.nextTick()
          .then(() => {
            const emitted = Object.keys(rootWrapper.emitted());

            expect(emitted).toEqual([BV_HIDE_TOOLTIP]);
            done();
          })
          .catch(done.fail);
      });
github gitlabhq / gitlabhq / spec / frontend / members / components / table / member_source_spec.js View on Github external
const getByText = (text, options) =>
    createWrapper(getByTextHelper(wrapper.element, text, options));
github gitlabhq / gitlabhq / spec / frontend / members / components / avatars / group_avatar_spec.js View on Github external
const getByText = (text, options) =>
    createWrapper(getByTextHelper(wrapper.element, text, options));
github gitlabhq / gitlabhq / spec / frontend / members / components / table / expires_at_spec.js View on Github external
const getByText = (text, options) =>
    createWrapper(within(wrapper.element).getByText(text, options));
github gitlabhq / gitlabhq / spec / frontend / members / index_spec.js View on Github external
const setup = () => {
    vm = initMembersApp(el, {
      [MEMBER_TYPES.user]: {
        tableFields: ['account'],
        tableAttrs: { table: { 'data-qa-selector': 'members_list' } },
        tableSortableFields: ['account'],
        requestFormatter: () => ({}),
        filteredSearchBar: { show: false },
      },
    });
    wrapper = createWrapper(vm);
  };
github gitlabhq / gitlabhq / spec / frontend / members / components / table / members_table_spec.js View on Github external
const getByText = (text, options) =>
    createWrapper(getByTextHelper(wrapper.element, text, options));