mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Test mocking the bootstrap-vue tooltip directive with a no-op; this way we can still get other warnings.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import DatasetName from "./DatasetName";
|
||||
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" } },
|
||||
localVue,
|
||||
});
|
||||
const state = wrapper.findAll(".name");
|
||||
expect(state.length).toBe(1);
|
||||
@@ -17,8 +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" } },
|
||||
localVue,
|
||||
});
|
||||
const state = wrapper.findAll(".name");
|
||||
expect(state.length).toBe(1);
|
||||
@@ -28,8 +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" } },
|
||||
localVue,
|
||||
});
|
||||
const state = wrapper.findAll(".name");
|
||||
expect(state.length).toBe(1);
|
||||
|
||||
@@ -3,20 +3,24 @@
|
||||
*/
|
||||
import { timer } from "rxjs";
|
||||
import { take } from "rxjs/operators";
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { createLocalVue, shallowMount } from "@vue/test-utils";
|
||||
|
||||
// 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
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,6 +53,16 @@ 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);
|
||||
return localVue;
|
||||
}
|
||||
|
||||
// Mounts a renderless component with sample content for testing
|
||||
export function mountRenderless(component, localVue, propsData) {
|
||||
return shallowMount(component, {
|
||||
|
||||
@@ -2,8 +2,4 @@ import "@testing-library/jest-dom";
|
||||
|
||||
/* still don't understand what was invoking the following, but nothing should,
|
||||
and this makes the tag tests work correctly */
|
||||
global.XMLHttpRequest = undefined;
|
||||
|
||||
// stops Bootstrap's warnings when components can't find a non-existent doc
|
||||
// https://github.com/bootstrap-vue/bootstrap-vue/issues/3303
|
||||
process.env.BOOTSTRAP_VUE_NO_WARN = true;
|
||||
global.XMLHttpRequest = undefined;
|
||||
Reference in New Issue
Block a user