mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -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",
|
"moduleFor": "off",
|
||||||
"moduleForComponent": "off",
|
"moduleForComponent": "off",
|
||||||
"testStart": "off",
|
"testStart": "off",
|
||||||
"testDone": "off"
|
"testDone": "off",
|
||||||
|
"sinon": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,26 +146,13 @@ var define, requirejs;
|
|||||||
"@ember/object/internals": {
|
"@ember/object/internals": {
|
||||||
guidFor: Ember.guidFor,
|
guidFor: Ember.guidFor,
|
||||||
},
|
},
|
||||||
|
"@ember/test-helpers": {
|
||||||
|
setResolver: window.setResolver,
|
||||||
|
},
|
||||||
I18n: {
|
I18n: {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
default: I18n,
|
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 QUnit from "qunit";
|
||||||
import MessageBus from "message-bus-client";
|
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 { setResolver } from "@ember/test-helpers";
|
||||||
|
|
||||||
export default function setupTests(App) {
|
export default function setupTests(App) {
|
||||||
window.setResolver(buildResolver("discourse").create({ namespace: App }));
|
setResolver(buildResolver("discourse").create({ namespace: App }));
|
||||||
|
|
||||||
sinon.config = {
|
sinon.config = {
|
||||||
injectIntoThis: false,
|
injectIntoThis: false,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// discourse-skip-module
|
// discourse-skip-module
|
||||||
|
|
||||||
/*global document, sinon, QUnit, Logster */
|
|
||||||
//= require env
|
//= require env
|
||||||
//= require jquery.debug
|
//= require jquery.debug
|
||||||
//= require jquery.ui.widget
|
//= require jquery.ui.widget
|
||||||
@ -41,8 +40,7 @@
|
|||||||
//= require_tree ../../admin/tests/admin
|
//= require_tree ../../admin/tests/admin
|
||||||
//= require plugin_tests
|
//= require plugin_tests
|
||||||
//= require setup-tests
|
//= require setup-tests
|
||||||
//= require_self
|
//= require test-shims
|
||||||
//
|
|
||||||
//= require jquery.magnific-popup.min.js
|
//= require jquery.magnific-popup.min.js
|
||||||
|
|
||||||
let setupTests = require("discourse/tests/setup-tests").default;
|
let setupTests = require("discourse/tests/setup-tests").default;
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
durationTiny,
|
durationTiny,
|
||||||
} from "discourse/lib/formatter";
|
} from "discourse/lib/formatter";
|
||||||
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import sinon from "sinon";
|
||||||
|
|
||||||
discourseModule("lib:formatter", {
|
discourseModule("lib:formatter", {
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
|
@ -4,6 +4,7 @@ import createStore from "discourse/tests/helpers/create-store";
|
|||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import { NotificationLevels } from "discourse/lib/notification-levels";
|
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
|
import sinon from "sinon";
|
||||||
|
|
||||||
module("model:topic-tracking-state", {
|
module("model:topic-tracking-state", {
|
||||||
beforeEach() {
|
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 ./models
|
||||||
//= require_tree ./components
|
//= require_tree ./components
|
||||||
//= require ./wizard-pretender
|
//= require ./wizard-pretender
|
||||||
|
//= require test-shims
|
||||||
|
|
||||||
// Trick JSHint into allow document.write
|
// Trick JSHint into allow document.write
|
||||||
var d = document;
|
var d = document;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import LocalDateBuilder from "./local-date-builder";
|
import LocalDateBuilder from "./local-date-builder";
|
||||||
|
import sinon from "sinon";
|
||||||
|
|
||||||
const UTC = "Etc/UTC";
|
const UTC = "Etc/UTC";
|
||||||
const SYDNEY = "Australia/Sydney";
|
const SYDNEY = "Australia/Sydney";
|
||||||
|
Loading…
Reference in New Issue
Block a user