mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:31:13 +08:00
Ember RC6 update
This commit is contained in:
@ -4,17 +4,20 @@ module("Discourse.Onebox", {
|
||||
}
|
||||
});
|
||||
|
||||
test("Stops rapid calls with cache true", function() {
|
||||
this.stub(Discourse, "ajax").returns(resolvingPromise);
|
||||
asyncTestDiscourse("Stops rapid calls with cache true", function() {
|
||||
this.stub(Discourse, "ajax").returns(Ember.RSVP.resolve());
|
||||
Discourse.Onebox.load(this.anchor, true);
|
||||
Discourse.Onebox.load(this.anchor, true);
|
||||
|
||||
Discourse.Onebox.load(this.anchor, true);
|
||||
Discourse.Onebox.load(this.anchor, true);
|
||||
start();
|
||||
ok(Discourse.ajax.calledOnce);
|
||||
});
|
||||
|
||||
test("Stops rapid calls with cache false", function() {
|
||||
this.stub(Discourse, "ajax").returns(resolvingPromise);
|
||||
asyncTestDiscourse("Stops rapid calls with cache true", function() {
|
||||
this.stub(Discourse, "ajax").returns(Ember.RSVP.resolve());
|
||||
Discourse.Onebox.load(this.anchor, false);
|
||||
Discourse.Onebox.load(this.anchor, false);
|
||||
|
||||
start();
|
||||
ok(Discourse.ajax.calledOnce);
|
||||
});
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ test("remove", function() {
|
||||
blank(PreloadStore.get('bane'), "removes the value if the key exists");
|
||||
});
|
||||
|
||||
asyncTest("getAndRemove returns a promise that resolves to null", function() {
|
||||
asyncTestDiscourse("getAndRemove returns a promise that resolves to null", function() {
|
||||
expect(1);
|
||||
|
||||
PreloadStore.getAndRemove('joker').then(function(result) {
|
||||
@ -23,7 +23,7 @@ asyncTest("getAndRemove returns a promise that resolves to null", function() {
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("getAndRemove returns a promise that resolves to the result of the finder", function() {
|
||||
asyncTestDiscourse("getAndRemove returns a promise that resolves to the result of the finder", function() {
|
||||
expect(1);
|
||||
|
||||
var finder = function() { return 'batdance'; };
|
||||
@ -34,7 +34,7 @@ asyncTest("getAndRemove returns a promise that resolves to the result of the fin
|
||||
|
||||
});
|
||||
|
||||
asyncTest("getAndRemove returns a promise that resolves to the result of the finder's promise", function() {
|
||||
asyncTestDiscourse("getAndRemove returns a promise that resolves to the result of the finder's promise", function() {
|
||||
expect(1);
|
||||
|
||||
var finder = function() {
|
||||
@ -47,7 +47,7 @@ asyncTest("getAndRemove returns a promise that resolves to the result of the fin
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("returns a promise that rejects with the result of the finder's rejected promise", function() {
|
||||
asyncTestDiscourse("returns a promise that rejects with the result of the finder's rejected promise", function() {
|
||||
expect(1);
|
||||
|
||||
var finder = function() {
|
||||
@ -61,7 +61,7 @@ asyncTest("returns a promise that rejects with the result of the finder's reject
|
||||
|
||||
});
|
||||
|
||||
asyncTest("returns a promise that resolves to 'evil'", function() {
|
||||
asyncTestDiscourse("returns a promise that resolves to 'evil'", function() {
|
||||
expect(1);
|
||||
|
||||
PreloadStore.getAndRemove('bane').then(function(result) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Test helpers
|
||||
var resolvingPromise = Ember.Deferred.promise(function (p) {
|
||||
p.resolve();
|
||||
});
|
||||
// var resolvingPromise = Ember.Deferred.promise(function (p) {
|
||||
// p.resolve();
|
||||
// });
|
||||
|
||||
var resolvingPromiseWith = function(result) {
|
||||
return Ember.Deferred.promise(function (p) { p.resolve(result); });
|
||||
};
|
||||
// var resolvingPromiseWith = function(result) {
|
||||
// return Ember.Deferred.promise(function (p) { p.resolve(result); });
|
||||
// };
|
||||
|
||||
function exists(selector) {
|
||||
return !!count(selector);
|
||||
|
@ -18,4 +18,15 @@ function controllerFor(controller, model) {
|
||||
var controller = Discourse.__container__.lookup('controller:' + controller);
|
||||
if (model) { controller.set('model', model ); }
|
||||
return controller;
|
||||
}
|
||||
|
||||
function asyncTestDiscourse(text, func) {
|
||||
|
||||
asyncTest(text, function () {
|
||||
|
||||
var qunitContext = this;
|
||||
Ember.run(function () {
|
||||
func.call(qunitContext);
|
||||
});
|
||||
});
|
||||
}
|
@ -8,7 +8,7 @@ var qHint = function(name, sourceFile, options, globals) {
|
||||
sourceFile = name;
|
||||
}
|
||||
|
||||
return asyncTest(name, function() {
|
||||
return asyncTestDiscourse(name, function() {
|
||||
qHint.sendRequest(sourceFile, function(req) {
|
||||
start();
|
||||
|
||||
@ -113,9 +113,8 @@ var jsHintOpts = {
|
||||
"visit",
|
||||
"count",
|
||||
"exists",
|
||||
"asyncTest",
|
||||
"asyncTestDiscourse",
|
||||
"find",
|
||||
"resolvingPromise",
|
||||
"sinon",
|
||||
"moment",
|
||||
"start",
|
||||
@ -125,7 +124,6 @@ var jsHintOpts = {
|
||||
"controllerFor",
|
||||
"containsInstance",
|
||||
"deepEqual",
|
||||
"resolvingPromiseWith",
|
||||
"Blob",
|
||||
"File"],
|
||||
"node" : false,
|
||||
|
@ -130,7 +130,7 @@ test('editingFirstPost', function() {
|
||||
|
||||
});
|
||||
|
||||
asyncTest('importQuote with a post', function() {
|
||||
asyncTestDiscourse('importQuote with a post', function() {
|
||||
expect(1);
|
||||
|
||||
this.stub(Discourse.Post, 'load').withArgs(123).returns(Em.Deferred.promise(function (p) {
|
||||
@ -144,7 +144,7 @@ asyncTest('importQuote with a post', function() {
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest('importQuote with no post', function() {
|
||||
asyncTestDiscourse('importQuote with no post', function() {
|
||||
expect(1);
|
||||
|
||||
this.stub(Discourse.Post, 'load').withArgs(4).returns(Em.Deferred.promise(function (p) {
|
||||
|
@ -213,7 +213,7 @@ test("identity map", function() {
|
||||
deepEqual(postStream.listUnloadedIds([1, 2, 3, 4]), [2, 4], "it only returns unloaded posts");
|
||||
});
|
||||
|
||||
asyncTest("loadIntoIdentityMap with no data", function() {
|
||||
asyncTestDiscourse("loadIntoIdentityMap with no data", function() {
|
||||
var postStream = buildStream(1234);
|
||||
expect(1);
|
||||
|
||||
@ -224,11 +224,11 @@ asyncTest("loadIntoIdentityMap with no data", function() {
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("loadIntoIdentityMap with post ids", function() {
|
||||
asyncTestDiscourse("loadIntoIdentityMap with post ids", function() {
|
||||
var postStream = buildStream(1234);
|
||||
expect(1);
|
||||
|
||||
this.stub(Discourse, "ajax").returns(resolvingPromiseWith({
|
||||
this.stub(Discourse, "ajax").returns(Ember.RSVP.resolve({
|
||||
post_stream: {
|
||||
posts: [{id: 10, post_number: 10}]
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Externals we need to load first
|
||||
//= require ../../app/assets/javascripts/external/jquery-1.9.1.js
|
||||
//= require ../../app/assets/javascripts/external/jquery.ui.widget.js
|
||||
//= require ../../app/assets/javascripts/external/handlebars-1.0.rc.4.js
|
||||
//= require ../../app/assets/javascripts/external/handlebars.js
|
||||
//= require ../../app/assets/javascripts/external_development/ember.js
|
||||
//= require ../../app/assets/javascripts/external_development/group-helper.js
|
||||
|
||||
|
Reference in New Issue
Block a user