mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #10904 from Nerdinacan/test_cleanup
Vue unit test cleanup, removing jquery, mocking ajax calls
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
"presets": ["@babel/preset-env"],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": ["@babel/plugin-transform-runtime", "rewire"]
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -115,8 +115,7 @@ framework.
|
||||
For testing Vue components, we use the [Vue testing
|
||||
utils](https://vue-test-utils.vuejs.org/) to mount individual components in a
|
||||
test bed and check them for rendered features. Please use jest-based mocking
|
||||
for isolating test functionality. Some tests exist using Rewire, but those
|
||||
should be updated over time.
|
||||
for isolating test functionality.
|
||||
|
||||
A set of older qUnit tests also exist which will be phased-out as the code they
|
||||
support is replaced with modern component-based implementations. In the
|
||||
|
||||
@@ -120,7 +120,6 @@
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^26.3.0",
|
||||
"babel-loader": "^8.1.0",
|
||||
"babel-plugin-rewire": "^1.2.0",
|
||||
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
||||
"babel-plugin-transform-vue-template": "^0.4.2",
|
||||
"chai": "^4.2.0",
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Model } from "./model";
|
||||
import { UrlTracker } from "./utilities";
|
||||
import { Services } from "./services";
|
||||
import { shallowMount, createLocalVue } from "@vue/test-utils";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
@@ -132,7 +131,6 @@ describe("DataDialog.vue", () => {
|
||||
const localVue = createLocalVue();
|
||||
wrapper = shallowMount(DataDialog, {
|
||||
propsData: mockOptions,
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
expect(wrapper.findComponent(SelectionDialog).exists()).toBe(true);
|
||||
@@ -145,7 +143,7 @@ describe("DataDialog.vue", () => {
|
||||
|
||||
// expect(wrapper.find(".fa-spinner").text()).to.equals("");
|
||||
// expect(wrapper.contains(".fa-spinner")).to.equals(true);
|
||||
// await Vue.nextTick();
|
||||
// await wrapper.vm.$nextTick();
|
||||
// expect(wrapper.findAll(".fa-folder").length).to.equals(2);
|
||||
// expect(wrapper.findAll(".fa-file-o").length).to.equals(2);
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import DatasetName from "./DatasetName";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
|
||||
const localVue = getLocalVue();
|
||||
|
||||
describe("Dataset Name", () => {
|
||||
it("test dataset default", async () => {
|
||||
const wrapper = mount(DatasetName, {
|
||||
const wrapper = shallowMount(DatasetName, {
|
||||
propsData: { item: { name: "name", state: "success" } },
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const state = wrapper.findAll(".name");
|
||||
expect(state.length).toBe(1);
|
||||
@@ -19,9 +21,9 @@ describe("Dataset Name", () => {
|
||||
expect(Array.isArray(wrapper.emitted().copyDataset)).toBe(true);
|
||||
});
|
||||
it("test dataset error", async () => {
|
||||
const wrapper = mount(DatasetName, {
|
||||
const wrapper = shallowMount(DatasetName, {
|
||||
propsData: { item: { name: "name", state: "error" } },
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const state = wrapper.findAll(".name");
|
||||
expect(state.length).toBe(1);
|
||||
@@ -31,9 +33,9 @@ describe("Dataset Name", () => {
|
||||
expect(errorstate.at(0).classes()).toEqual(expect.arrayContaining(["text-danger"]));
|
||||
});
|
||||
it("test dataset paused", async () => {
|
||||
const wrapper = mount(DatasetName, {
|
||||
const wrapper = shallowMount(DatasetName, {
|
||||
propsData: { item: { name: "name", state: "paused" } },
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const state = wrapper.findAll(".name");
|
||||
expect(state.length).toBe(1);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import InteractiveTools from "./InteractiveTools";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import flushPromises from "flush-promises";
|
||||
import _l from "utils/localization";
|
||||
import testInteractiveToolsResponse from "./testData/testInteractiveToolsResponse";
|
||||
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import axios from "axios";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
describe("InteractiveTools/InteractiveTools.vue", () => {
|
||||
const localVue = createLocalVue();
|
||||
const localVue = getLocalVue();
|
||||
localVue.filter("localize", (value) => _l(value));
|
||||
let wrapper;
|
||||
let axiosMock;
|
||||
@@ -24,7 +24,7 @@ describe("InteractiveTools/InteractiveTools.vue", () => {
|
||||
};
|
||||
},
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
axiosMock.onGet("/api/entry_points?running=true").reply(200, testInteractiveToolsResponse);
|
||||
axiosMock.onPost("/interactivetool/list").reply(200, { status: "ok", message: "ok" });
|
||||
|
||||
@@ -1,34 +1,43 @@
|
||||
import Vuex from "vuex";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import { createStore } from "../../store";
|
||||
import { shallowMount, createLocalVue } from "@vue/test-utils";
|
||||
import createCache from "vuex-cache";
|
||||
import JobDestinationParams from "./JobDestinationParams";
|
||||
import jobDestinationResponse from "./testData/jobDestinationResponse";
|
||||
|
||||
const JOB_ID = "foo_job_id";
|
||||
|
||||
describe("JobDestinationParams/JobDestinationParams.vue", () => {
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
|
||||
const responseKeys = Object.keys(jobDestinationResponse);
|
||||
|
||||
let testStore;
|
||||
let wrapper;
|
||||
|
||||
beforeEach(async () => {
|
||||
testStore = createStore();
|
||||
const propsData = {
|
||||
jobId: JOB_ID,
|
||||
};
|
||||
wrapper = mount(JobDestinationParams, {
|
||||
store: testStore,
|
||||
propsData,
|
||||
localVue,
|
||||
computed: {
|
||||
jobDestinationParams() {
|
||||
const testStore = new Vuex.Store({
|
||||
plugins: [createCache()],
|
||||
modules: {
|
||||
jobDestinationParametersStore: {
|
||||
actions: {
|
||||
fetchJobDestinationParams: jest.fn(),
|
||||
},
|
||||
getters: {
|
||||
jobDestinationParams: (state) => (job_id) => {
|
||||
return jobDestinationResponse;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe("JobDestinationParams/JobDestinationParams.vue", () => {
|
||||
const responseKeys = Object.keys(jobDestinationResponse);
|
||||
|
||||
let wrapper;
|
||||
|
||||
beforeEach(async () => {
|
||||
const propsData = {
|
||||
jobId: JOB_ID,
|
||||
};
|
||||
wrapper = shallowMount(JobDestinationParams, {
|
||||
store: testStore,
|
||||
propsData,
|
||||
localVue,
|
||||
});
|
||||
expect(responseKeys.length > 0).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import MarkdownVisualization from "./MarkdownVisualization";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import Vue from "vue";
|
||||
|
||||
describe("Markdown/MarkdownVisualization", () => {
|
||||
it("test wizard", async () => {
|
||||
@@ -16,7 +15,7 @@ describe("Markdown/MarkdownVisualization", () => {
|
||||
useLabels: false,
|
||||
},
|
||||
});
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.labelShow).toBe(false);
|
||||
expect(Object.keys(wrapper.vm.formInputs).length).toBe(3);
|
||||
wrapper.vm.onData("history_dataset_id");
|
||||
@@ -35,7 +34,7 @@ describe("Markdown/MarkdownVisualization", () => {
|
||||
useLabels: true,
|
||||
},
|
||||
});
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.labelShow).toBe(true);
|
||||
expect(wrapper.vm.formInputs).toBe(null);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { default as Masthead, __RewireAPI__ as rewire } from "./Masthead.vue";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import { default as Masthead } from "./Masthead.vue";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import Scratchbook from "layout/scratchbook";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
import { fetchMenu } from "layout/menu";
|
||||
import { loadWebhookMenuItems } from "./_webhooks";
|
||||
|
||||
jest.mock("app");
|
||||
jest.mock("layout/menu");
|
||||
jest.mock("./_webhooks");
|
||||
|
||||
describe("Masthead.vue", () => {
|
||||
let wrapper;
|
||||
@@ -24,11 +30,11 @@ describe("Masthead.vue", () => {
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__("fetchMenu", stubFetchMenu);
|
||||
rewire.__Rewire__("loadWebhookMenuItems", stubLoadWebhooks);
|
||||
fetchMenu.mockImplementation(stubFetchMenu);
|
||||
loadWebhookMenuItems.mockImplementation(stubLoadWebhooks);
|
||||
|
||||
localVue = createLocalVue();
|
||||
beforeEach(() => {
|
||||
localVue = getLocalVue();
|
||||
quotaRendered = false;
|
||||
quotaEl = null;
|
||||
|
||||
@@ -83,7 +89,6 @@ describe("Masthead.vue", () => {
|
||||
appRoot: "prefix/",
|
||||
},
|
||||
localVue,
|
||||
attachTo: getNewAttachNode(),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import MastheadItem from "./MastheadItem.vue";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
describe("Masthead.vue", () => {
|
||||
describe("MastheadItem.vue", () => {
|
||||
let wrapper;
|
||||
let localVue;
|
||||
let active;
|
||||
let menu;
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue();
|
||||
localVue = getLocalVue();
|
||||
});
|
||||
|
||||
function m() {
|
||||
@@ -18,13 +18,12 @@ describe("Masthead.vue", () => {
|
||||
menu: menu,
|
||||
};
|
||||
|
||||
return mount(MastheadItem, {
|
||||
return shallowMount(MastheadItem, {
|
||||
propsData: {
|
||||
tab,
|
||||
activeTab: active,
|
||||
},
|
||||
localVue,
|
||||
attachTo: getNewAttachNode(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import Tool from "./Tool";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
const localVue = getLocalVue();
|
||||
|
||||
describe("Tool", () => {
|
||||
test("test tool", () => {
|
||||
@@ -8,7 +10,7 @@ describe("Tool", () => {
|
||||
propsData: {
|
||||
tool: {},
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const nameElement = wrapper.findAll(".name");
|
||||
expect(nameElement.at(0).text()).toBe("");
|
||||
@@ -30,7 +32,7 @@ describe("Tool", () => {
|
||||
operationIcon: "operationIconClass",
|
||||
operationTitle: "operationTitle",
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const nameElement = wrapper.findAll(".name");
|
||||
expect(nameElement.at(0).text()).toBe("name");
|
||||
@@ -48,7 +50,7 @@ describe("Tool", () => {
|
||||
},
|
||||
hideName: true,
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const nameElement = wrapper.findAll(".name");
|
||||
expect(nameElement.length).toBe(0);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Vue from "vue";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import ToolSection from "./ToolSection";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
const localVue = getLocalVue();
|
||||
|
||||
describe("ToolSection", () => {
|
||||
test("test tool section", () => {
|
||||
@@ -11,7 +12,7 @@ describe("ToolSection", () => {
|
||||
name: "name",
|
||||
},
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const nameElement = wrapper.findAll(".name");
|
||||
expect(nameElement.at(0).text()).toBe("name");
|
||||
@@ -34,19 +35,19 @@ describe("ToolSection", () => {
|
||||
],
|
||||
},
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
expect(wrapper.vm.opened).toBe(false);
|
||||
const $sectionName = wrapper.find(".name");
|
||||
expect($sectionName.text()).toBe("tool_section");
|
||||
$sectionName.trigger("click");
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
const $names = wrapper.findAll(".name");
|
||||
expect($names.at(1).text()).toBe("name");
|
||||
const $label = wrapper.find(".tool-panel-label");
|
||||
expect($label.text()).toBe("text");
|
||||
$sectionName.trigger("click");
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.findAll(".name").length).toBe(1);
|
||||
});
|
||||
|
||||
@@ -66,30 +67,30 @@ describe("ToolSection", () => {
|
||||
},
|
||||
queryFilter: "test",
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
expect(wrapper.vm.opened).toBe(true);
|
||||
const $sectionName = wrapper.find(".name");
|
||||
$sectionName.trigger("click");
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.opened).toBe(false);
|
||||
wrapper.setProps({ queryFilter: "" });
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.opened).toBe(false);
|
||||
wrapper.setProps({ queryFilter: "test" });
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.opened).toBe(true);
|
||||
wrapper.setProps({ disableFilter: true });
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.opened).toBe(true);
|
||||
wrapper.setProps({ queryFilter: "" });
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.opened).toBe(false);
|
||||
$sectionName.trigger("click");
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.opened).toBe(true);
|
||||
wrapper.setProps({ queryFilter: "test" });
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.vm.opened).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import Vue from "vue";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import SavedRulesSelector from "components/RuleBuilder/SavedRulesSelector";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
const localVue = getLocalVue();
|
||||
|
||||
describe("SavedRulesSelector", () => {
|
||||
let wrapper;
|
||||
@@ -14,13 +15,13 @@ describe("SavedRulesSelector", () => {
|
||||
prefix: "test_prefix_" + new Date().toISOString() + "_",
|
||||
savedRules: [],
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
});
|
||||
|
||||
it("disables history icon if there is no history", async () => {
|
||||
@@ -49,7 +50,7 @@ describe("SavedRulesSelector", () => {
|
||||
user: "test_user",
|
||||
savedRules: [testRules],
|
||||
});
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
const sessions = wrapper.findAll("div.dropdown-menu > a.saved-rule-item");
|
||||
expect(sessions.length > 0).toBeTruthy();
|
||||
sessions.wrappers[0].trigger("click");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import StatelessTags from "./StatelessTags";
|
||||
import _l from "utils/localization";
|
||||
import Vue from "vue";
|
||||
|
||||
describe("Tags/StatelessTags.vue", () => {
|
||||
const localVue = createLocalVue();
|
||||
@@ -17,7 +16,7 @@ describe("Tags/StatelessTags.vue", () => {
|
||||
value: testTags,
|
||||
});
|
||||
emitted = wrapper.emitted();
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
});
|
||||
|
||||
it("should render a div for each tag", () => {
|
||||
|
||||
@@ -3,7 +3,6 @@ import ToolsJson from "./ToolsJson";
|
||||
import testToolsListResponse from "../testData/toolsList";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import axios from "axios";
|
||||
import Vue from "vue";
|
||||
import { mount } from "@vue/test-utils";
|
||||
|
||||
describe("ToolsView/ToolsView.vue", () => {
|
||||
@@ -15,11 +14,11 @@ describe("ToolsView/ToolsView.vue", () => {
|
||||
axiosMock = new MockAdapter(axios);
|
||||
wrapper = mount(ToolsJson);
|
||||
axiosMock.onGet("/api/tools?tool_help=True").reply(200, testToolsListResponse);
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
});
|
||||
|
||||
it("schema.org script element is created", async () => {
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
const tools = wrapper.vm.createToolsJson(testToolsListResponse);
|
||||
const schemaElement = document.getElementById("schema-json");
|
||||
const schemaText = JSON.parse(schemaElement.text);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import ToolsView from "./ToolsView";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import _l from "utils/localization";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import flushPromises from "flush-promises";
|
||||
|
||||
// test response
|
||||
@@ -9,15 +9,17 @@ import testCitation from "./testData/citation";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import axios from "axios";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
describe("ToolsView/ToolsView.vue", () => {
|
||||
const localVue = createLocalVue();
|
||||
localVue.filter("localize", (value) => _l(value));
|
||||
const localVue = getLocalVue();
|
||||
|
||||
let wrapper;
|
||||
let axiosMock;
|
||||
|
||||
beforeEach(async () => {
|
||||
axiosMock = new MockAdapter(axios);
|
||||
wrapper = mount(ToolsView);
|
||||
wrapper = mount(ToolsView, { localVue });
|
||||
axiosMock.onGet("/api/tools?tool_help=True").reply(200, testToolsListResponse);
|
||||
axiosMock.onGet(new RegExp(`./*/citations`)).reply(200, testCitation);
|
||||
await flushPromises();
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { shallowMount, createLocalVue } from "@vue/test-utils";
|
||||
import Details from "./Details";
|
||||
import { __RewireAPI__ as rewire } from "./Details";
|
||||
import Vue from "vue";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
import { getAppRoot } from "onload/loadConfig";
|
||||
jest.mock("onload/loadConfig");
|
||||
getAppRoot.mockImplementation(() => "/");
|
||||
|
||||
import { Services } from "../services";
|
||||
jest.mock("../services");
|
||||
|
||||
Services.mockImplementation(() => {
|
||||
return {
|
||||
async getRepositoryByName(url, name, owner) {
|
||||
expect(url).toBe("tool_shed_url");
|
||||
expect(name).toBe("name");
|
||||
expect(owner).toBe("owner");
|
||||
return {};
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("Details", () => {
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__(
|
||||
"Services",
|
||||
class {
|
||||
async getRepositoryByName(url, name, owner) {
|
||||
expect(url).toBe("tool_shed_url");
|
||||
expect(name).toBe("name");
|
||||
expect(owner).toBe("owner");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const localVue = createLocalVue();
|
||||
it("test repository details loading", async () => {
|
||||
const wrapper = shallowMount(Details, {
|
||||
propsData: {
|
||||
@@ -27,11 +32,12 @@ describe("Details", () => {
|
||||
owner: "owner",
|
||||
},
|
||||
},
|
||||
localVue,
|
||||
});
|
||||
expect(wrapper.findAll("loading-span-stub").length).toBe(1);
|
||||
expect(wrapper.find("loading-span-stub").attributes("message")).toBe("Loading installed repository details");
|
||||
expect(wrapper.findAll("repositorydetails-stub").length).toBe(0);
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(wrapper.findAll("loading-span-stub").length).toBe(0);
|
||||
expect(wrapper.findAll(".alert").length).toBe(0);
|
||||
expect(wrapper.findAll("repositorydetails-stub").length).toBe(1);
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import Index from "./Index";
|
||||
import { __RewireAPI__ as rewire } from "./Index";
|
||||
import Vue from "vue";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
import { getAppRoot } from "onload/loadConfig";
|
||||
jest.mock("onload/loadConfig");
|
||||
getAppRoot.mockImplementation(() => "/");
|
||||
|
||||
import { Services } from "../services";
|
||||
jest.mock("../services");
|
||||
|
||||
Services.mockImplementation(() => {
|
||||
return {
|
||||
async getInstalledRepositories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
description: "description_0",
|
||||
tool_shed_status: {
|
||||
latest_installable_revision: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
description: "description_1",
|
||||
tool_shed_status: {
|
||||
latest_installable_revision: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("InstalledList", () => {
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__(
|
||||
"Services",
|
||||
class {
|
||||
async getInstalledRepositories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
description: "description_0",
|
||||
tool_shed_status: {
|
||||
latest_installable_revision: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
description: "description_1",
|
||||
tool_shed_status: {
|
||||
latest_installable_revision: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("test installed list", async () => {
|
||||
const wrapper = mount(Index, {
|
||||
propsData: {
|
||||
@@ -40,7 +44,7 @@ describe("InstalledList", () => {
|
||||
},
|
||||
});
|
||||
expect(wrapper.find(".loading-message").text()).toBe("Loading installed repositories...");
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.find(".installed-message").text()).toBe("2 repositories installed on this instance.");
|
||||
const names = wrapper.findAll(".name");
|
||||
expect(names.length).toBe(2);
|
||||
|
||||
@@ -1,36 +1,41 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { createLocalVue, mount } from "@vue/test-utils";
|
||||
import Monitor from "./Monitor";
|
||||
import { __RewireAPI__ as rewire } from "./Monitor";
|
||||
import Vue from "vue";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
import { getAppRoot } from "onload/loadConfig";
|
||||
jest.mock("onload/loadConfig");
|
||||
getAppRoot.mockImplementation(() => "/");
|
||||
|
||||
import { Services } from "../services";
|
||||
jest.mock("../services");
|
||||
|
||||
Services.mockImplementation(() => {
|
||||
return {
|
||||
async getInstalledRepositories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
owner: "owner_0",
|
||||
status: "status_0_0",
|
||||
description: "description_0_0",
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
owner: "owner_1",
|
||||
status: "status_1",
|
||||
description: "description_1",
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("Monitor", () => {
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__(
|
||||
"Services",
|
||||
class {
|
||||
async getInstalledRepositories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
owner: "owner_0",
|
||||
status: "status_0_0",
|
||||
description: "description_0_0",
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
owner: "owner_1",
|
||||
status: "status_1",
|
||||
description: "description_1",
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("test monitor", async () => {
|
||||
const wrapper = mount(Monitor, {});
|
||||
await Vue.nextTick();
|
||||
const localVue = createLocalVue();
|
||||
const wrapper = mount(Monitor, localVue);
|
||||
await localVue.nextTick();
|
||||
const headers = wrapper.findAll("th");
|
||||
expect(headers.length).toBe(2);
|
||||
expect(headers.at(0).text()).toBe("Name");
|
||||
|
||||
@@ -1,29 +1,34 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { shallowMount, createLocalVue } from "@vue/test-utils";
|
||||
import Index from "./Index";
|
||||
import { __RewireAPI__ as rewire } from "./Index";
|
||||
import Vue from "vue";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
import { getAppRoot } from "onload/loadConfig";
|
||||
jest.mock("onload/loadConfig");
|
||||
getAppRoot.mockImplementation(() => "/");
|
||||
|
||||
import { Services } from "../services";
|
||||
jest.mock("../services");
|
||||
|
||||
Services.mockImplementation(() => {
|
||||
return {
|
||||
async getRepository(toolshedUrl, repositoryId) {
|
||||
expect(toolshedUrl).toBe("toolshedUrl");
|
||||
expect(repositoryId).toBe("id");
|
||||
return [];
|
||||
},
|
||||
async getInstalledRepositoriesByName(name, owner) {
|
||||
expect(name).toBe("name");
|
||||
expect(owner).toBe("owner");
|
||||
return [];
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("RepositoryDetails", () => {
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__(
|
||||
"Services",
|
||||
class {
|
||||
async getRepository(toolshedUrl, repositoryId) {
|
||||
expect(toolshedUrl).toBe("toolshedUrl");
|
||||
expect(repositoryId).toBe("id");
|
||||
return [];
|
||||
}
|
||||
async getInstalledRepositoriesByName(name, owner) {
|
||||
expect(name).toBe("name");
|
||||
expect(owner).toBe("owner");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("test repository details index", async () => {
|
||||
const wrapper = mount(Index, {
|
||||
const localVue = createLocalVue();
|
||||
const wrapper = shallowMount(Index, {
|
||||
propsData: {
|
||||
repo: {
|
||||
id: "id",
|
||||
@@ -33,16 +38,12 @@ describe("RepositoryDetails", () => {
|
||||
},
|
||||
toolshedUrl: "toolshedUrl",
|
||||
},
|
||||
stubs: {
|
||||
RepositoryDetails: true,
|
||||
InstallationSettings: true,
|
||||
RepositoryTools: true,
|
||||
},
|
||||
localVue,
|
||||
});
|
||||
expect(wrapper.find(".loading-message").text()).toBe("Loading repository details...");
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(wrapper.findAll(".alert").length).toBe(0);
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(wrapper.findAll(".alert").length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import InstallationSettings from "./InstallationSettings";
|
||||
import { __RewireAPI__ as rewire } from "./InstallationSettings";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
describe("InstallationSettings", () => {
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__("getGalaxyInstance", () => {
|
||||
return {
|
||||
config: {},
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
it("test tool repository installer interface", () => {
|
||||
const wrapper = mount(InstallationSettings, {
|
||||
propsData: {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import Vue from "vue";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import RepositoryTools from "./RepositoryTools";
|
||||
|
||||
@@ -57,7 +56,7 @@ describe("RepositoryTools", () => {
|
||||
expect($third.find("td:last-child").text()).toBe("");
|
||||
const $link = wrapper.find("a");
|
||||
$link.trigger("click");
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
const $elExpanded = wrapper.findAll("tr");
|
||||
expect($elExpanded.length).toBe(4);
|
||||
@@ -69,7 +68,7 @@ describe("RepositoryTools", () => {
|
||||
expect($forthExpanded.find("td:last-child").text()).toBe("");
|
||||
const $linkExpanded = wrapper.find("a");
|
||||
$linkExpanded.trigger("click");
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
const $elCollapsed = wrapper.findAll("tr");
|
||||
expect($elCollapsed.length).toBe(3);
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import Categories from "./Categories";
|
||||
import { __RewireAPI__ as rewire } from "./Categories";
|
||||
import Vue from "vue";
|
||||
|
||||
import { Services } from "../services";
|
||||
jest.mock("../services");
|
||||
|
||||
Services.mockImplementation(() => {
|
||||
return {
|
||||
async getCategories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
description: "description_0",
|
||||
repositories: "repositories_0",
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
description: "description_1",
|
||||
repositories: "repositories_1",
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("Categories", () => {
|
||||
let localVue;
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__(
|
||||
"Services",
|
||||
class {
|
||||
async getCategories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
description: "description_0",
|
||||
repositories: "repositories_0",
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
description: "description_1",
|
||||
repositories: "repositories_1",
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
);
|
||||
localVue = createLocalVue();
|
||||
});
|
||||
|
||||
it("test categories loading", () => {
|
||||
@@ -32,6 +35,7 @@ describe("Categories", () => {
|
||||
loading: true,
|
||||
toolshedUrl: "toolshedUrl",
|
||||
},
|
||||
localVue,
|
||||
});
|
||||
expect(wrapper.find(".loading-message").text()).toBe("Loading categories...");
|
||||
});
|
||||
@@ -42,8 +46,9 @@ describe("Categories", () => {
|
||||
loading: false,
|
||||
toolshedUrl: "toolshedUrl",
|
||||
},
|
||||
localVue,
|
||||
});
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
const links = wrapper.findAll("a");
|
||||
expect(links.length).toBe(2);
|
||||
expect(links.at(0).text()).toBe("name_0");
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import Repositories from "./Repositories";
|
||||
import { __RewireAPI__ as rewire } from "./Repositories";
|
||||
import Vue from "vue";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
import { Services } from "../services";
|
||||
jest.mock("../services");
|
||||
|
||||
Services.mockImplementation(() => {
|
||||
return {
|
||||
async getRepositories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
owner: "owner_0",
|
||||
last_updated: "last_updated_0",
|
||||
times_downloaded: "times_downloaded_0",
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
owner: "owner_1",
|
||||
last_updated: "last_updated_1",
|
||||
times_downloaded: "times_downloaded_1",
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("Repositories", () => {
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__(
|
||||
"Services",
|
||||
class {
|
||||
async getRepositories() {
|
||||
return [
|
||||
{
|
||||
name: "name_0",
|
||||
owner: "owner_0",
|
||||
last_updated: "last_updated_0",
|
||||
times_downloaded: "times_downloaded_0",
|
||||
},
|
||||
{
|
||||
name: "name_1",
|
||||
owner: "owner_1",
|
||||
last_updated: "last_updated_1",
|
||||
times_downloaded: "times_downloaded_1",
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
const localVue = createLocalVue();
|
||||
|
||||
it("test repository details loading", async () => {
|
||||
const wrapper = mount(Repositories, {
|
||||
@@ -35,10 +37,11 @@ describe("Repositories", () => {
|
||||
scrolled: false,
|
||||
toolshedUrl: "toolshedUrl",
|
||||
},
|
||||
localVue,
|
||||
});
|
||||
// Test initial state prior to the data fetch tick -- should be loading.
|
||||
expect(wrapper.find(".loading-message").text()).toBe("Loading repositories...");
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
const links = wrapper.findAll("a");
|
||||
expect(links.length).toBe(2);
|
||||
expect(links.at(0).text()).toBe("name_0");
|
||||
@@ -46,7 +49,7 @@ describe("Repositories", () => {
|
||||
// Reset repositories and state to test empty.
|
||||
wrapper.vm.repositories = [];
|
||||
wrapper.vm.pageState = 2; // COMPLETE is '2'
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(wrapper.find(".unavailable-message").text()).toBe("No matching repositories found.");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import flushPromises from "flush-promises";
|
||||
import { shallowMount, createLocalVue } from "@vue/test-utils";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
|
||||
import { default as CloudAuth } from "./CloudAuth";
|
||||
import CloudAuthItem from "./CloudAuthItem";
|
||||
@@ -7,8 +8,6 @@ import CloudAuthItem from "./CloudAuthItem";
|
||||
import _l from "utils/localization";
|
||||
import BootstrapVue from "bootstrap-vue";
|
||||
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
jest.mock("./model/service", () => ({
|
||||
listCredentials: async () => {
|
||||
const listCredentials = require("./testdata/listCredentials.json");
|
||||
@@ -17,7 +16,7 @@ jest.mock("./model/service", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
const localVue = createLocalVue();
|
||||
const localVue = getLocalVue();
|
||||
localVue.use(BootstrapVue);
|
||||
localVue.filter("localize", (value) => _l(value));
|
||||
|
||||
@@ -25,7 +24,7 @@ describe("CloudAuth component", () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(async () => {
|
||||
wrapper = shallowMount(CloudAuth, { localVue, attachTo: getNewAttachNode() });
|
||||
wrapper = shallowMount(CloudAuth, { localVue });
|
||||
await flushPromises();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
import Vue from "vue";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { mount, createLocalVue } from "@vue/test-utils";
|
||||
import Attributes from "./Attributes";
|
||||
import { __RewireAPI__ as rewire } from "./Attributes";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
import { Services } from "../services";
|
||||
jest.mock("../services");
|
||||
|
||||
Services.mockImplementation(() => {
|
||||
return {
|
||||
async updateWorkflow() {
|
||||
return {};
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe("Attributes", () => {
|
||||
beforeEach(() => {
|
||||
rewire.__Rewire__(
|
||||
"Services",
|
||||
class {
|
||||
async updateWorkflow() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
it("test attributes", async () => {
|
||||
const localVue = createLocalVue();
|
||||
const wrapper = mount(Attributes, {
|
||||
propsData: {
|
||||
id: "workflow_id",
|
||||
@@ -26,11 +28,12 @@ describe("Attributes", () => {
|
||||
stubs: {
|
||||
LicenseSelector: true,
|
||||
},
|
||||
localVue,
|
||||
});
|
||||
const name = wrapper.find("#workflow-name");
|
||||
expect(name.element.value).toBe("workflow_name");
|
||||
wrapper.setProps({ name: "new_workflow_name" });
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(name.element.value).toBe("new_workflow_name");
|
||||
const parameters = wrapper.findAll(".list-group-item");
|
||||
expect(parameters.length).toBe(2);
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import Node from "./Node";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
import flushPromises from "flush-promises";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
const localVue = getLocalVue();
|
||||
|
||||
describe("Node", () => {
|
||||
it("test attributes", async () => {
|
||||
const wrapper = mount(Node, {
|
||||
const wrapper = shallowMount(Node, {
|
||||
propsData: {
|
||||
id: "node-id",
|
||||
name: "node-name",
|
||||
@@ -15,8 +17,9 @@ describe("Node", () => {
|
||||
step: {},
|
||||
getManager: () => {},
|
||||
getCanvasManager: () => {},
|
||||
datatypesMapper: {},
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
await flushPromises();
|
||||
const icon = wrapper.findAll("i");
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
import Vue from "vue";
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { getLocalVue } from "jest/helpers";
|
||||
import ZoomControl from "./ZoomControl";
|
||||
import { getNewAttachNode } from "jest/helpers";
|
||||
|
||||
jest.mock("app");
|
||||
|
||||
describe("ZoomControl", () => {
|
||||
it("test zoom control", async () => {
|
||||
const localVue = getLocalVue();
|
||||
const wrapper = mount(ZoomControl, {
|
||||
propsData: {
|
||||
zoomLevel: 10,
|
||||
},
|
||||
attachTo: getNewAttachNode(),
|
||||
localVue,
|
||||
});
|
||||
const buttons = wrapper.findAll("button");
|
||||
expect(buttons.length).toBe(3);
|
||||
buttons.at(0).trigger("click");
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(wrapper.emitted().onZoom[0][0]).toBe(9);
|
||||
buttons.at(1).trigger("click");
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(wrapper.emitted().onZoom[1][0]).toBe(10);
|
||||
buttons.at(2).trigger("click");
|
||||
await Vue.nextTick();
|
||||
await localVue.nextTick();
|
||||
expect(wrapper.emitted().onZoom[2][0]).toBe(11);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import BaseList from "./BaseList";
|
||||
import Vue from "vue";
|
||||
|
||||
describe("Categories", () => {
|
||||
const getter = async () => {
|
||||
@@ -32,7 +31,7 @@ describe("Categories", () => {
|
||||
setter: setter,
|
||||
},
|
||||
});
|
||||
await Vue.nextTick();
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.find(".card-header").text()).toContain("There are 2");
|
||||
const th = wrapper.findAll("th");
|
||||
expect(th.length).toBe(3);
|
||||
|
||||
@@ -3,28 +3,26 @@
|
||||
*/
|
||||
import { timer } from "rxjs";
|
||||
import { take } from "rxjs/operators";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { createLocalVue, shallowMount } from "@vue/test-utils";
|
||||
import { localizationPlugin } from "components/plugins";
|
||||
|
||||
export function getNewAttachNode() {
|
||||
const attachElement = document.createElement("div");
|
||||
if (document.body) {
|
||||
document.body.appendChild(attachElement);
|
||||
}
|
||||
return attachElement;
|
||||
}
|
||||
|
||||
// Creates a watcher on the indicated vm/prop for use in testing
|
||||
export function watchForChange({ vm, opts, propName, timeout = 1000, label = '' }) {
|
||||
export function watchForChange({ vm, opts, propName, timeout = 1000, label = "" }) {
|
||||
const start = new Date();
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeoutID = setTimeout(() => {
|
||||
reject(`${propName} never changed ${label}`);
|
||||
}, timeout);
|
||||
vm.$watch(propName, function (newVal, oldVal) {
|
||||
clearTimeout(timeoutID);
|
||||
const stop = new Date();
|
||||
resolve({ timeElapsed: stop - start, newVal, oldVal });
|
||||
}, opts);
|
||||
vm.$watch(
|
||||
propName,
|
||||
function (newVal, oldVal) {
|
||||
clearTimeout(timeoutID);
|
||||
const stop = new Date();
|
||||
resolve({ timeElapsed: stop - start, newVal, oldVal });
|
||||
},
|
||||
opts
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,6 +55,18 @@ export const showAll = (vm) => {
|
||||
// usage: await wait(500);
|
||||
export const wait = (n) => timer(n).pipe(take(1)).toPromise();
|
||||
|
||||
// Gets a localVue with custom directives
|
||||
export function getLocalVue() {
|
||||
const localVue = createLocalVue();
|
||||
const mockedDirective = {
|
||||
bind() {},
|
||||
};
|
||||
localVue.directive("b-tooltip", mockedDirective);
|
||||
localVue.directive("b-popover", mockedDirective);
|
||||
localVue.use(localizationPlugin);
|
||||
return localVue;
|
||||
}
|
||||
|
||||
// Mounts a renderless component with sample content for testing
|
||||
export function mountRenderless(component, localVue, propsData) {
|
||||
return shallowMount(component, {
|
||||
|
||||
@@ -84,7 +84,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
||||
// modulePathIgnorePatterns: [],
|
||||
modulePathIgnorePatterns: ["<rootDir>/src/.*/__mocks__"],
|
||||
|
||||
// Activates notifications for test results
|
||||
// notify: false,
|
||||
|
||||
@@ -31,18 +31,12 @@ module.exports = (env, argv) => {
|
||||
|
||||
wpConfig.module = merge.smart(wpConfig.module, ignoreAssetLoaders);
|
||||
|
||||
// Using babel-plugin-rewire to handle dependency mocking since webpack 4
|
||||
// exports immutable bindings for ES modules but we still need a way to
|
||||
// overwrite dependencies during unit-testing.
|
||||
//
|
||||
// Additionally, set exclude for babel-loader to completely ignore *all*
|
||||
// node-modules, without our exceptions to support IE as in parent webpack
|
||||
// config.
|
||||
// Set exclude for babel-loader to completely ignore *all* node-modules,
|
||||
// without our exceptions to support IE as in parent webpack config.
|
||||
|
||||
wpConfig.module.rules = wpConfig.module.rules.map((rule) => {
|
||||
if (rule.loader == "babel-loader") {
|
||||
rule.exclude = [/(node_modules\/)/];
|
||||
rule.options.plugins.push("rewire");
|
||||
}
|
||||
return rule;
|
||||
});
|
||||
|
||||
+4
-29
@@ -3041,11 +3041,6 @@ babel-plugin-jest-hoist@^26.2.0:
|
||||
"@types/babel__core" "^7.0.0"
|
||||
"@types/babel__traverse" "^7.0.6"
|
||||
|
||||
babel-plugin-rewire@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-rewire/-/babel-plugin-rewire-1.2.0.tgz#822562d72ed2c84e47c0f95ee232c920853e9d89"
|
||||
integrity sha512-JBZxczHw3tScS+djy6JPLMjblchGhLI89ep15H3SyjujIzlxo5nr6Yjo7AXotdeVczeBmWs0tF8PgJWDdgzAkQ==
|
||||
|
||||
babel-plugin-transform-es2015-modules-commonjs@^6.26.0:
|
||||
version "6.26.2"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3"
|
||||
@@ -3748,30 +3743,10 @@ caniuse-api@^3.0.0:
|
||||
lodash.memoize "^4.1.2"
|
||||
lodash.uniq "^4.5.0"
|
||||
|
||||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000890:
|
||||
version "1.0.30000893"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000893.tgz#284b20932bd41b93e21626975f2050cb01561986"
|
||||
integrity sha512-kOddHcTEef+NgN/fs0zmX2brHTNATVOWMEIhlZHCuwQRtXobjSw9pAECc44Op4bTBcavRjkLaPrGomknH7+Jvg==
|
||||
|
||||
caniuse-lite@^1.0.30000929:
|
||||
version "1.0.30000953"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000953.tgz#8054c4e5c4aa69dc3269353a4a5e102909759dbb"
|
||||
integrity sha512-2stdF/q5MZTDhQ6uC65HWbSgI9UMKbc7+HKvlwH5JBIslKoD/J9dvabP4J4Uiifu3NljbHj3iMpfYflLSNt09A==
|
||||
|
||||
caniuse-lite@^1.0.30000989, caniuse-lite@^1.0.30001061:
|
||||
version "1.0.30001062"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz#d814b648338504b315222ace6f1a533d9a55e390"
|
||||
integrity sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==
|
||||
|
||||
caniuse-lite@^1.0.30001022:
|
||||
version "1.0.30001022"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001022.tgz#9eeffe580c3a8f110b7b1742dcf06a395885e4c6"
|
||||
integrity sha512-FjwPPtt/I07KyLPkBQ0g7/XuZg6oUkYBVnPHNj3VHJbOjmmJ/GdSo/GUY6MwINEQvjhP6WZVbX8Tvms8xh0D5A==
|
||||
|
||||
caniuse-lite@^1.0.30001043:
|
||||
version "1.0.30001053"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001053.tgz#b7ae027567ce2665b965b0437e4512b296ccd20d"
|
||||
integrity sha512-HtV4wwIZl6GA4Oznse8aR274XUOYGZnQLcf/P8vHgmlfqSNelwD+id8CyHOceqLqt9yfKmo7DUZTh1EuS9pukg==
|
||||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000890, caniuse-lite@^1.0.30000929, caniuse-lite@^1.0.30000989, caniuse-lite@^1.0.30001022, caniuse-lite@^1.0.30001043, caniuse-lite@^1.0.30001061:
|
||||
version "1.0.30001168"
|
||||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001168.tgz"
|
||||
integrity sha512-P2zmX7swIXKu+GMMR01TWa4csIKELTNnZKc+f1CjebmZJQtTAEXmpQSoKVJVVcvPGAA0TEYTOUp3VehavZSFPQ==
|
||||
|
||||
capture-exit@^2.0.0:
|
||||
version "2.0.0"
|
||||
|
||||
Reference in New Issue
Block a user