Add stub_out_jquery() for node tests.

This commit is contained in:
Steve Howell 2016-07-30 11:01:15 -07:00 committed by Tim Abbott
parent 6ce8f3da6d
commit ebe76dd2c3
10 changed files with 23 additions and 45 deletions

View File

@ -1,11 +1,4 @@
set_global('$', function () {
return {
on: function () {
return;
}
};
});
$.fn = {};
global.stub_out_jquery();
add_dependencies({
util: 'js/util.js',

View File

@ -2,13 +2,7 @@
var path = require('path');
var fs = require('fs');
set_global('$', function () {
return {
on: function () {
return;
}
};
});
global.stub_out_jquery();
set_global('page_params', {realm_emoji: {
burrito: {display_url: '/static/third/gemoji/images/emoji/burrito.png',

View File

@ -10,12 +10,8 @@ add_dependencies({
set_global('document', null);
set_global('$', function () {
return {
on: function () {},
trigger: function () {}
};
});
global.stub_out_jquery();
set_global('feature_flags', {});
set_global('Filter', function () {});

View File

@ -2,13 +2,7 @@ add_dependencies({
util: 'js/util.js'
});
set_global('$', function () {
return {
on: function () {
return;
}
};
});
global.stub_out_jquery();
var people = require("js/people.js");

View File

@ -1,12 +1,5 @@
// TODO: de-dup with activity.js
set_global('$', function () {
return {
on: function () {
return;
}
};
});
$.fn = {};
global.stub_out_jquery();
set_global('document', {
hasFocus: function () {

View File

@ -11,13 +11,8 @@ set_global('document', {});
set_global('window', {
addEventListener: noop
});
set_global('$', function () {
return {
hide: noop,
trigger: noop
};
});
global.$.now = noop;
global.stub_out_jquery();
// Prevent the get_events loop and watchdog from running
patch_builtin('setTimeout', noop);

View File

@ -1,4 +1,4 @@
set_global('$', function (f) {});
global.stub_out_jquery();
var stream_color = require('js/stream_color.js');

View File

@ -1,4 +1,4 @@
set_global('$', function () {});
global.stub_out_jquery();
add_dependencies({
Handlebars: 'handlebars',

View File

@ -17,6 +17,7 @@ var namespace = require('./namespace.js');
global.set_global = namespace.set_global;
global.patch_builtin = namespace.patch_builtin;
global.add_dependencies = namespace.add_dependencies;
global.stub_out_jquery = namespace.stub_out_jquery;
// Set up helpers to render templates.
var render = require('./render.js');

View File

@ -39,6 +39,18 @@ exports.restore = function () {
old_builtins = {};
};
exports.stub_out_jquery = function () {
set_global('$', function () {
return {
on: function () {},
trigger: function () {},
hide: function () {}
};
});
$.fn = {};
$.now = function () {};
};
return exports;
}());
module.exports = namespace;