mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
REFACTOR: Use imports for sinon
and setResolver
I also took the opportunity with this commit to move some test specific stuff out of `discourse-loader` which is loaded on the front end of the application. The test module building now happens in the `test_helper` bundle.
This commit is contained in:
parent
4326827a4e
commit
3862036422
@ -7,6 +7,7 @@
|
||||
"moduleFor": "off",
|
||||
"moduleForComponent": "off",
|
||||
"testStart": "off",
|
||||
"testDone": "off"
|
||||
"testDone": "off",
|
||||
"sinon": "off"
|
||||
}
|
||||
}
|
||||
|
@ -146,26 +146,13 @@ var define, requirejs;
|
||||
"@ember/object/internals": {
|
||||
guidFor: Ember.guidFor,
|
||||
},
|
||||
"@ember/test-helpers": {
|
||||
setResolver: window.setResolver,
|
||||
},
|
||||
I18n: {
|
||||
// eslint-disable-next-line
|
||||
default: I18n,
|
||||
},
|
||||
pretender: {
|
||||
default: window.Pretender,
|
||||
},
|
||||
"ember-qunit": {
|
||||
moduleFor: window.moduleFor,
|
||||
moduleForComponent: window.moduleForComponent,
|
||||
},
|
||||
qunit:
|
||||
typeof window.QUnit !== "undefined"
|
||||
? {
|
||||
default: window.QUnit,
|
||||
test: window.QUnit.test,
|
||||
skip: window.QUnit.skip,
|
||||
module: window.QUnit.module,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,11 @@ import { clearAppEventsCache } from "discourse/services/app-events";
|
||||
import QUnit from "qunit";
|
||||
import MessageBus from "message-bus-client";
|
||||
import deprecated from "discourse-common/lib/deprecated";
|
||||
import sinon from "sinon";
|
||||
import { setResolver } from "@ember/test-helpers";
|
||||
|
||||
export default function setupTests(App) {
|
||||
window.setResolver(buildResolver("discourse").create({ namespace: App }));
|
||||
setResolver(buildResolver("discourse").create({ namespace: App }));
|
||||
|
||||
sinon.config = {
|
||||
injectIntoThis: false,
|
||||
|
@ -1,6 +1,5 @@
|
||||
// discourse-skip-module
|
||||
|
||||
/*global document, sinon, QUnit, Logster */
|
||||
//= require env
|
||||
//= require jquery.debug
|
||||
//= require jquery.ui.widget
|
||||
@ -41,8 +40,7 @@
|
||||
//= require_tree ../../admin/tests/admin
|
||||
//= require plugin_tests
|
||||
//= require setup-tests
|
||||
//= require_self
|
||||
//
|
||||
//= require test-shims
|
||||
//= require jquery.magnific-popup.min.js
|
||||
|
||||
let setupTests = require("discourse/tests/setup-tests").default;
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
durationTiny,
|
||||
} from "discourse/lib/formatter";
|
||||
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||
import sinon from "sinon";
|
||||
|
||||
discourseModule("lib:formatter", {
|
||||
beforeEach() {
|
||||
|
@ -4,6 +4,7 @@ import createStore from "discourse/tests/helpers/create-store";
|
||||
import Category from "discourse/models/category";
|
||||
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||
import User from "discourse/models/user";
|
||||
import sinon from "sinon";
|
||||
|
||||
module("model:topic-tracking-state", {
|
||||
beforeEach() {
|
||||
|
27
app/assets/javascripts/test-shims.js
Normal file
27
app/assets/javascripts/test-shims.js
Normal file
@ -0,0 +1,27 @@
|
||||
// discourse-skip-module
|
||||
|
||||
define("sinon", () => {
|
||||
return { default: window.sinon };
|
||||
});
|
||||
define("qunit", () => {
|
||||
return {
|
||||
default: window.QUnit,
|
||||
test: window.QUnit.test,
|
||||
skip: window.QUnit.skip,
|
||||
module: window.QUnit.module,
|
||||
};
|
||||
});
|
||||
define("ember-qunit", () => {
|
||||
return {
|
||||
moduleFor: window.moduleFor,
|
||||
moduleForComponent: window.moduleForComponent,
|
||||
};
|
||||
});
|
||||
define("@ember/test-helpers", () => {
|
||||
return {
|
||||
setResolver: window.setResolver,
|
||||
};
|
||||
});
|
||||
define("pretender", () => {
|
||||
return { default: window.Pretender };
|
||||
});
|
@ -23,6 +23,7 @@
|
||||
//= require_tree ./models
|
||||
//= require_tree ./components
|
||||
//= require ./wizard-pretender
|
||||
//= require test-shims
|
||||
|
||||
// Trick JSHint into allow document.write
|
||||
var d = document;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import I18n from "I18n";
|
||||
import LocalDateBuilder from "./local-date-builder";
|
||||
import sinon from "sinon";
|
||||
|
||||
const UTC = "Etc/UTC";
|
||||
const SYDNEY = "Australia/Sydney";
|
||||
|
Loading…
Reference in New Issue
Block a user