mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:09:18 +08:00
Removed bad JS tests, upgrade QUnit + ember-qunit
This commit is contained in:
parent
4df868a420
commit
01d4085125
2
Gemfile
2
Gemfile
|
@ -124,7 +124,7 @@ group :test, :development do
|
|||
gem 'certified', require: false
|
||||
# later appears to break Fabricate(:topic, category: category)
|
||||
gem 'fabrication', '2.9.8', require: false
|
||||
gem 'qunit-rails'
|
||||
gem 'discourse-qunit-rails', require: 'qunit-rails'
|
||||
gem 'mocha', require: false
|
||||
gem 'rb-fsevent', require: RUBY_PLATFORM =~ /darwin/i ? 'rb-fsevent' : false
|
||||
gem 'rb-inotify', '~> 0.9', require: RUBY_PLATFORM =~ /linux/i ? 'rb-inotify' : false
|
||||
|
|
|
@ -64,6 +64,8 @@ GEM
|
|||
daemons (1.2.2)
|
||||
debug_inspector (0.0.2)
|
||||
diff-lcs (1.2.5)
|
||||
discourse-qunit-rails (0.0.8)
|
||||
railties
|
||||
docile (1.1.5)
|
||||
dotenv (1.0.2)
|
||||
email_reply_parser (0.5.8)
|
||||
|
@ -291,8 +293,6 @@ GEM
|
|||
pry (>= 0.9.10)
|
||||
puma (2.11.1)
|
||||
rack (>= 1.1, < 2.0)
|
||||
qunit-rails (0.0.7)
|
||||
railties
|
||||
r2 (0.2.5)
|
||||
rack (1.5.3)
|
||||
rack-mini-profiler (0.9.3)
|
||||
|
@ -464,6 +464,7 @@ DEPENDENCIES
|
|||
better_errors
|
||||
binding_of_caller
|
||||
certified
|
||||
discourse-qunit-rails
|
||||
email_reply_parser
|
||||
ember-rails
|
||||
ember-source (= 1.11.3.1)
|
||||
|
@ -510,7 +511,6 @@ DEPENDENCIES
|
|||
pry-nav
|
||||
pry-rails
|
||||
puma
|
||||
qunit-rails
|
||||
r2 (~> 0.2.5)
|
||||
rack-mini-profiler
|
||||
rack-protection
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
moduleFor("controller:admin-site-settings");
|
||||
|
||||
test("filter", function() {
|
||||
var allSettings = [
|
||||
Ember.Object.create({
|
||||
nameKey: 'users', name: 'users',
|
||||
siteSettings: [Discourse.SiteSetting.create({"setting":"username_change_period","description":"x","default":3,"type":"fixnum","value":"3","category":"users"})]
|
||||
}),
|
||||
Ember.Object.create({
|
||||
nameKey: 'posting', name: 'posting',
|
||||
siteSettings: [Discourse.SiteSetting.create({"setting":"display_name_on_posts","description":"x","default":false,"type":"bool","value":"true","category":"posting"})]
|
||||
})
|
||||
];
|
||||
|
||||
var adminSiteSettingsController = this.subject({ model: allSettings });
|
||||
sinon.stub(adminSiteSettingsController, "transitionToRoute");
|
||||
|
||||
adminSiteSettingsController.set('allSiteSettings', allSettings);
|
||||
equal(adminSiteSettingsController.get('content')[0].nameKey, 'users', "Can get first site setting category's name key.");
|
||||
|
||||
adminSiteSettingsController.set('filter', 'username_change');
|
||||
equal(adminSiteSettingsController.get('content').length, 1, "Filter with one match for username_change");
|
||||
equal(adminSiteSettingsController.get('content')[0].nameKey, "all_results", "First element is all the results that match");
|
||||
equal(adminSiteSettingsController.get('content')[0].siteSettings[0].setting, "username_change_period", "Filter with one match for username_change");
|
||||
|
||||
adminSiteSettingsController.setProperties({ filter: '', onlyOverridden: true });
|
||||
equal(adminSiteSettingsController.get('content').length, 1, "onlyOverridden with one match");
|
||||
equal(adminSiteSettingsController.get('content')[0].nameKey, "all_results", "onlyOverridden with one match");
|
||||
equal(adminSiteSettingsController.get('content')[0].siteSettings[0].setting, "display_name_on_posts", "onlyOverridden with one match");
|
||||
|
||||
});
|
6
test/javascripts/components/ace-editor-test.js.es6
Normal file
6
test/javascripts/components/ace-editor-test.js.es6
Normal file
|
@ -0,0 +1,6 @@
|
|||
moduleForComponent('ace-editor', {needs: []});
|
||||
|
||||
test('changing colors', function(assert) {
|
||||
assert.expect(0);
|
||||
var component = this.subject();
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
moduleForComponent("text-field");
|
||||
moduleForComponent("text-field", {needs: []});
|
||||
|
||||
test("renders correctly with no properties set", function() {
|
||||
var component = this.subject();
|
|
@ -1,14 +1,5 @@
|
|||
moduleFor("controller:user-dropdown");
|
||||
|
||||
test("logout action logs out the current user", function () {
|
||||
const logoutMock = sinon.mock(Discourse, "logout");
|
||||
logoutMock.expects("logout").once();
|
||||
|
||||
this.subject().send('logout');
|
||||
|
||||
logoutMock.verify();
|
||||
});
|
||||
|
||||
test("showAdminLinks", function() {
|
||||
const currentUser = Ember.Object.create({ staff: true });
|
||||
const controller = this.subject({ currentUser });
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
/* global emq */
|
||||
|
||||
var resolver = require('discourse/ember/resolver').default;
|
||||
emq.globalize();
|
||||
emq.setResolver(resolver.create({ namespace: Discourse }));
|
||||
window.setResolver(resolver.create({ namespace: Discourse }));
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
var clock, original, debounced;
|
||||
|
||||
var firedOnce = function(message) {
|
||||
ok(original.calledOnce, message);
|
||||
};
|
||||
|
||||
var firedTwice = function(message) {
|
||||
ok(original.calledTwice, message);
|
||||
};
|
||||
|
||||
var notFired = function(message) {
|
||||
ok(!original.called, message);
|
||||
};
|
||||
|
||||
module("Discourse.debounce", {
|
||||
setup: function() {
|
||||
clock = sinon.useFakeTimers();
|
||||
original = sinon.spy();
|
||||
debounced = Discourse.debounce(original, 100);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
clock.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test("delays function execution till the end of the timeout", function() {
|
||||
debounced();
|
||||
notFired("immediately after calling debounced function nothing happens");
|
||||
|
||||
clock.tick(99);
|
||||
notFired("just before the end of the timeout still nothing happens");
|
||||
|
||||
clock.tick(1);
|
||||
firedOnce("exactly at the end of the timeout the function is executed");
|
||||
});
|
||||
|
||||
test("executes delayed function only once, no matter how many times debounced function is called during the timeout", function() {
|
||||
debounced();
|
||||
debounced();
|
||||
|
||||
clock.tick(100);
|
||||
firedOnce("second call was supressed");
|
||||
});
|
||||
|
||||
test("prolongs the timeout when the debounced function is called for the second time during the timeout", function() {
|
||||
debounced();
|
||||
|
||||
clock.tick(50);
|
||||
debounced();
|
||||
|
||||
clock.tick(50);
|
||||
notFired("at the end of the original timeout nothing happens");
|
||||
|
||||
clock.tick(50);
|
||||
firedOnce("function is executed exactly at the end of the prolonged timeout");
|
||||
});
|
||||
|
||||
test("preserves last call's context and params when executing delayed function", function() {
|
||||
var firstObj = {};
|
||||
var secondObj = {};
|
||||
|
||||
debounced.call(firstObj, "first");
|
||||
debounced.call(secondObj, "second");
|
||||
|
||||
clock.tick(100);
|
||||
ok(original.calledOn(secondObj), "the context of the last of two subsequent calls is preserved");
|
||||
ok(original.calledWithExactly("second"), "param passed during the last of two subsequent calls is preserved");
|
||||
});
|
||||
|
||||
test("can be called again after timeout passes", function() {
|
||||
var firstObj = {};
|
||||
var secondObj = {};
|
||||
|
||||
debounced.call(firstObj, "first");
|
||||
|
||||
clock.tick(100);
|
||||
debounced.call(secondObj, "second");
|
||||
|
||||
clock.tick(100);
|
||||
firedTwice();
|
||||
});
|
|
@ -14,35 +14,3 @@ test("isInternal with a HTTPS url", function() {
|
|||
sandbox.stub(Discourse.URL, "origin").returns("https://eviltrout.com");
|
||||
ok(Discourse.URL.isInternal("http://eviltrout.com/monocle"), "HTTPS urls match HTTP urls");
|
||||
});
|
||||
|
||||
// --------------------------------------------
|
||||
// I DON'T KNOW WHY THIS BREAKS OTHER TESTS :(
|
||||
// --------------------------------------------
|
||||
|
||||
// test("routeTo", function() {
|
||||
// sandbox.stub(Discourse.URL, "handleURL", function (path) { return path === "/t/topic-title/42"; });
|
||||
|
||||
// ok(Discourse.URL.routeTo("https://discourse.org/t/topic-title/42"), "can route HTTPS");
|
||||
// ok(Discourse.URL.routeTo("http://discourse.org/t/topic-title/42"), "can route HTTP");
|
||||
// ok(Discourse.URL.routeTo("//discourse.org/t/topic-title/42"), "can route schemaless");
|
||||
// ok(Discourse.URL.routeTo("/t/topic-title/42"), "can route relative");
|
||||
// });
|
||||
|
||||
// TODO pending: this works but the test is too mocky and needs to be fixed
|
||||
|
||||
// test("navigatedToHome", function() {
|
||||
// var fakeDiscoveryController = { send: function() { return true; } };
|
||||
// var mock = sinon.mock(fakeDiscoveryController);
|
||||
// sandbox.stub(Discourse.URL, "controllerFor").returns(fakeDiscoveryController);
|
||||
//
|
||||
// mock.expects("send").withArgs('refresh').twice();
|
||||
// ok(Discourse.URL.navigatedToHome("/", "/"));
|
||||
//
|
||||
// var homepage = "/" + Discourse.Utilities.defaultHomepage();
|
||||
// ok(Discourse.URL.navigatedToHome(homepage, "/"));
|
||||
//
|
||||
// not(Discourse.URL.navigatedToHome("/old", "/new"));
|
||||
//
|
||||
// // make sure we called the .refresh() method
|
||||
// mock.verify();
|
||||
// });
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
//= require admin
|
||||
//= require_tree ../../app/assets/javascripts/defer
|
||||
|
||||
|
||||
//= require sinon-1.7.1
|
||||
//= require sinon-qunit-1.0.0
|
||||
//= require jshint
|
||||
|
@ -50,15 +49,6 @@
|
|||
//
|
||||
//= require ../../public/javascripts/jquery.magnific-popup-min.js
|
||||
|
||||
// sinon settings
|
||||
sinon.config = {
|
||||
injectIntoThis: true,
|
||||
injectInto: null,
|
||||
properties: ["spy", "stub", "mock", "clock", "sandbox"],
|
||||
useFakeTimers: false,
|
||||
useFakeServer: false
|
||||
};
|
||||
|
||||
window.assetPath = function(url) {
|
||||
if (url.indexOf('defer') === 0) {
|
||||
return "/assets/" + url;
|
||||
|
@ -103,7 +93,6 @@ QUnit.testStart(function(ctx) {
|
|||
PreloadStore.reset();
|
||||
|
||||
window.sandbox = sinon.sandbox.create();
|
||||
|
||||
window.sandbox.stub(Discourse.ScrollingDOMMethods, "bindOnScroll");
|
||||
window.sandbox.stub(Discourse.ScrollingDOMMethods, "unbindOnScroll");
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
moduleFor("view:header");
|
||||
|
||||
test("showNotifications", function() {
|
||||
var controllerSpy = {
|
||||
send: sinon.spy()
|
||||
};
|
||||
var view = this.subject({controller: controllerSpy});
|
||||
view.showNotifications();
|
||||
|
||||
ok(controllerSpy.send.calledWith("showNotifications", view), "sends showNotifications message to the controller, passing header view as a param");
|
||||
});
|
1316
vendor/assets/javascripts/ember-qunit.js
vendored
1316
vendor/assets/javascripts/ember-qunit.js
vendored
File diff suppressed because it is too large
Load Diff
14
vendor/assets/javascripts/sinon-qunit-1.0.0.js
vendored
14
vendor/assets/javascripts/sinon-qunit-1.0.0.js
vendored
|
@ -41,21 +41,9 @@ sinon.assert.pass = function (assertion) {
|
|||
};
|
||||
|
||||
sinon.config = {
|
||||
injectIntoThis: true,
|
||||
injectIntoThis: false,
|
||||
injectInto: null,
|
||||
properties: ["spy", "stub", "mock", "clock", "sandbox"],
|
||||
useFakeTimers: true,
|
||||
useFakeServer: false
|
||||
};
|
||||
|
||||
(function (global) {
|
||||
var qTest = QUnit.test;
|
||||
|
||||
QUnit.test = global.test = function (testName, expected, callback, async) {
|
||||
if (arguments.length === 2) {
|
||||
callback = expected;
|
||||
expected = null;
|
||||
}
|
||||
return qTest(testName, expected, sinon.test(callback), async);
|
||||
};
|
||||
}(this));
|
||||
|
|
Loading…
Reference in New Issue
Block a user