FIX: Modal methods should be wired up in `setupTests` not in module
This commit is contained in:
parent
331236d6d7
commit
625cf5a8ae
|
@ -32,7 +32,6 @@ import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
||||||
import { setURLContainer } from "discourse/lib/url";
|
import { setURLContainer } from "discourse/lib/url";
|
||||||
import { setDefaultOwner } from "discourse-common/lib/get-owner";
|
import { setDefaultOwner } from "discourse-common/lib/get-owner";
|
||||||
import bootbox from "bootbox";
|
|
||||||
import { moduleFor } from "ember-qunit";
|
import { moduleFor } from "ember-qunit";
|
||||||
import QUnit, { module } from "qunit";
|
import QUnit, { module } from "qunit";
|
||||||
import siteFixtures from "discourse/tests/fixtures/site-fixtures";
|
import siteFixtures from "discourse/tests/fixtures/site-fixtures";
|
||||||
|
@ -68,36 +67,6 @@ export function fakeTime(timeString, timezone = null, advanceTime = false) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const Plugin = $.fn.modal;
|
|
||||||
const Modal = Plugin.Constructor;
|
|
||||||
|
|
||||||
function AcceptanceModal(option, _relatedTarget) {
|
|
||||||
return this.each(function () {
|
|
||||||
var $this = $(this);
|
|
||||||
var data = $this.data("bs.modal");
|
|
||||||
var options = $.extend(
|
|
||||||
{},
|
|
||||||
Modal.DEFAULTS,
|
|
||||||
$this.data(),
|
|
||||||
typeof option === "object" && option
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
$this.data("bs.modal", (data = new Modal(this, options)));
|
|
||||||
}
|
|
||||||
data.$body = $("#ember-testing");
|
|
||||||
|
|
||||||
if (typeof option === "string") {
|
|
||||||
data[option](_relatedTarget);
|
|
||||||
} else if (options.show) {
|
|
||||||
data.show(_relatedTarget);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bootbox.$body = $("#ember-testing");
|
|
||||||
$.fn.modal = AcceptanceModal;
|
|
||||||
|
|
||||||
let _pretenderCallbacks = {};
|
let _pretenderCallbacks = {};
|
||||||
|
|
||||||
export function resetSite(siteSettings, extras) {
|
export function resetSite(siteSettings, extras) {
|
||||||
|
|
|
@ -26,6 +26,34 @@ import MessageBus from "message-bus-client";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { setApplication, setResolver } from "@ember/test-helpers";
|
import { setApplication, setResolver } from "@ember/test-helpers";
|
||||||
|
import bootbox from "bootbox";
|
||||||
|
|
||||||
|
const Plugin = $.fn.modal;
|
||||||
|
const Modal = Plugin.Constructor;
|
||||||
|
|
||||||
|
function AcceptanceModal(option, _relatedTarget) {
|
||||||
|
return this.each(function () {
|
||||||
|
var $this = $(this);
|
||||||
|
var data = $this.data("bs.modal");
|
||||||
|
var options = $.extend(
|
||||||
|
{},
|
||||||
|
Modal.DEFAULTS,
|
||||||
|
$this.data(),
|
||||||
|
typeof option === "object" && option
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
$this.data("bs.modal", (data = new Modal(this, options)));
|
||||||
|
}
|
||||||
|
data.$body = $("#ember-testing");
|
||||||
|
|
||||||
|
if (typeof option === "string") {
|
||||||
|
data[option](_relatedTarget);
|
||||||
|
} else if (options.show) {
|
||||||
|
data.show(_relatedTarget);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default function setupTests(app, container) {
|
export default function setupTests(app, container) {
|
||||||
setResolver(buildResolver("discourse").create({ namespace: app }));
|
setResolver(buildResolver("discourse").create({ namespace: app }));
|
||||||
|
@ -45,6 +73,8 @@ export default function setupTests(app, container) {
|
||||||
app.setupForTesting();
|
app.setupForTesting();
|
||||||
app.SiteSettings = currentSettings();
|
app.SiteSettings = currentSettings();
|
||||||
app.start();
|
app.start();
|
||||||
|
bootbox.$body = $("#ember-testing");
|
||||||
|
$.fn.modal = AcceptanceModal;
|
||||||
|
|
||||||
// disable logster error reporting
|
// disable logster error reporting
|
||||||
if (window.Logster) {
|
if (window.Logster) {
|
||||||
|
|
Loading…
Reference in New Issue