Upgrade QUnit to latest version
This commit is contained in:
@@ -8,14 +8,6 @@ function count(selector) {
|
||||
return find(selector).length;
|
||||
}
|
||||
|
||||
function containsInstance(collection, klass, text) {
|
||||
ok(klass.detectInstance(_.first(collection)), text);
|
||||
}
|
||||
|
||||
function not(state, message) {
|
||||
ok(!state, message);
|
||||
}
|
||||
|
||||
function visible(selector) {
|
||||
return find(selector + ":visible").length > 0;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ export default function(name, opts) {
|
||||
|
||||
this.registry.register('store:main', store, { instantiate: false });
|
||||
|
||||
if (opts.setup) {
|
||||
opts.setup.call(this, store);
|
||||
if (opts.beforeEach) {
|
||||
opts.beforeEach.call(this, store);
|
||||
}
|
||||
|
||||
andThen(() => {
|
||||
|
||||
@@ -379,4 +379,4 @@ export default function() {
|
||||
|
||||
server.checkPassthrough = request => request.requestHeaders['Discourse-Script'];
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,11 @@ export default function() {
|
||||
register: {
|
||||
lookup(type) {
|
||||
if (type === "adapter:rest") {
|
||||
this._restAdapter = this._restAdapter || RestAdapter.create({ container: this });
|
||||
return (this._restAdapter);
|
||||
if (!this._restAdapter) {
|
||||
this._restAdapter = RestAdapter.create({ owner: this });
|
||||
// this._restAdapter.container = this;
|
||||
}
|
||||
return this._restAdapter;
|
||||
}
|
||||
if (type === "key-value-store:main") {
|
||||
this._kvs = this._kvs || new KeyValueStore();
|
||||
@@ -34,5 +37,4 @@ export default function() {
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,4 +5,4 @@ export default function parseHTML(rawHtml) {
|
||||
|
||||
parser.parseComplete(rawHtml);
|
||||
return builder.dom;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* global asyncTest, fixtures */
|
||||
/* global QUnit, fixtures */
|
||||
|
||||
import sessionFixtures from 'fixtures/session-fixtures';
|
||||
import siteFixtures from 'fixtures/site-fixtures';
|
||||
@@ -41,7 +41,7 @@ $.fn.modal = AcceptanceModal;
|
||||
|
||||
function acceptance(name, options) {
|
||||
module("Acceptance: " + name, {
|
||||
setup() {
|
||||
beforeEach() {
|
||||
resetMobile();
|
||||
|
||||
// For now don't do scrolling stuff in Test Mode
|
||||
@@ -50,8 +50,8 @@ function acceptance(name, options) {
|
||||
resetExtraClasses();
|
||||
const siteJson = siteFixtures['site.json'].site;
|
||||
if (options) {
|
||||
if (options.setup) {
|
||||
options.setup.call(this);
|
||||
if (options.beforeEach) {
|
||||
options.beforeEach.call(this);
|
||||
}
|
||||
|
||||
if (options.mobileView) {
|
||||
@@ -77,9 +77,9 @@ function acceptance(name, options) {
|
||||
Discourse.reset();
|
||||
},
|
||||
|
||||
teardown() {
|
||||
if (options && options.teardown) {
|
||||
options.teardown.call(this);
|
||||
afterEach() {
|
||||
if (options && options.afterEach) {
|
||||
options.afterEach.call(this);
|
||||
}
|
||||
flushMap();
|
||||
Discourse.User.resetCurrent();
|
||||
@@ -102,10 +102,11 @@ function controllerFor(controller, model) {
|
||||
}
|
||||
|
||||
function asyncTestDiscourse(text, func) {
|
||||
asyncTest(text, function () {
|
||||
var self = this;
|
||||
Ember.run(function () {
|
||||
func.call(self);
|
||||
QUnit.test(text, function(assert) {
|
||||
const done = assert.async();
|
||||
Ember.run(() => {
|
||||
func.call(this, assert);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -117,20 +118,46 @@ function fixture(selector) {
|
||||
return $("#qunit-fixture");
|
||||
}
|
||||
|
||||
function present(obj, text) {
|
||||
ok(!Ember.isEmpty(obj), text);
|
||||
}
|
||||
QUnit.assert.not = function(actual, message) {
|
||||
this.pushResult({
|
||||
result: !actual,
|
||||
actual,
|
||||
expected: !actual,
|
||||
message
|
||||
});
|
||||
};
|
||||
|
||||
function blank(obj, text) {
|
||||
ok(Ember.isEmpty(obj), text);
|
||||
}
|
||||
QUnit.assert.blank = function(actual, message) {
|
||||
this.pushResult({
|
||||
result: Ember.isEmpty(actual),
|
||||
actual,
|
||||
message
|
||||
});
|
||||
};
|
||||
|
||||
function waitFor(callback, timeout) {
|
||||
QUnit.assert.present = function(actual, message) {
|
||||
this.pushResult({
|
||||
result: !Ember.isEmpty(actual),
|
||||
actual,
|
||||
message
|
||||
});
|
||||
};
|
||||
|
||||
QUnit.assert.containsInstance = function(collection, klass, message) {
|
||||
const result = klass.detectInstance(_.first(collection));
|
||||
this.pushResult({
|
||||
result,
|
||||
message
|
||||
});
|
||||
};
|
||||
|
||||
function waitFor(assert, callback, timeout) {
|
||||
timeout = timeout || 500;
|
||||
stop();
|
||||
|
||||
const done = assert.async();
|
||||
Ember.run.later(() => {
|
||||
callback();
|
||||
start();
|
||||
done();
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
@@ -140,6 +167,4 @@ export { acceptance,
|
||||
fixture,
|
||||
logIn,
|
||||
currentUser,
|
||||
blank,
|
||||
present,
|
||||
waitFor };
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -76,4 +76,4 @@ export default function(helpers) {
|
||||
});
|
||||
|
||||
this.delete('/widgets/:widget_id', success);
|
||||
};
|
||||
};
|
||||
@@ -6,4 +6,4 @@ export function moduleForWidget(name) {
|
||||
|
||||
export function widgetTest(name, opts) {
|
||||
return componentTest(name, opts);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user