Ejemplo n.º 1
1
global.createComponentMocks = ({ store, router, style, mocks, stubs }) => {
  const localVue = vueTestUtils.createLocalVue()
  const returnOptions = { localVue }
  returnOptions.stubs = mocks || {}
  returnOptions.mocks = stubs || {}

  if (store) {
    localVue.use(Vuex)
    returnOptions.store = new Vuex.Store({
      state: store.state || {},
      getters: store.getters || {},
      actions: store.actions || {},
    })
  }

  if (router) {
    returnOptions.stubs['router-link'] = true
    returnOptions.stubs['router-view'] = true
  }

  if (style) {
    returnOptions.mocks.$style = style
  }

  return returnOptions
}
Ejemplo n.º 2
0
import { shallow, createLocalVue } from "vue-test-utils";
import { createRenderer } from "vue-server-renderer";
import Vuex from "vuex";

import NavigationBar from "@/components/NavigationBar";
import * as actionTypes from "@/store/actionTypes";

const localVue = createLocalVue();

localVue.use(Vuex);

describe("NavigationBar.vue when logged in", () => {
    let wrapper;

    let actions;
    let state;
    let store;

    beforeEach(() => {
        actions = {
            [actionTypes.LOGOUT]: jest.fn(),
        };
        state = {
            auth: {
                loggedIn: true,
            },
            user: {
                username: "Username",
            },
        };
        store = new Vuex.Store({