mirror of https://github.com/zulip/zulip.git
Add the "static" directory to NODE_PATH for unit tests.
I added our "static" directory to NODE_PATH for our JS unit tests. This eliminates most of the verbosity in our require statements, but it still requires us to explicitly call out "js" or "third" subdirectories, which should make it a bit easier for folks reading the tests to distinguish modules from js, third, or node itself. (imported from commit b77a5283135d388d46f4b7e511acc59986f1a8ba)
This commit is contained in:
parent
44e59dfaea
commit
2442edee9e
|
@ -2,6 +2,10 @@
|
|||
|
||||
cd "$(dirname "$0")"/../zephyr/tests/frontend/node
|
||||
|
||||
STATIC_DIR=`python -c 'import os;print os.path.realpath("../../../../static")'`
|
||||
|
||||
export NODE_PATH=$STATIC_DIR
|
||||
|
||||
NODEJS=$(which nodejs || which node)
|
||||
|
||||
$NODEJS message_tour.js
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// purpose, but, briefly, it provides an API to keep track of
|
||||
// messages that you visit on a "tour."
|
||||
|
||||
var message_tour = require('../../../../static/js/message_tour.js');
|
||||
var message_tour = require('js/message_tour.js');
|
||||
var assert = require('assert');
|
||||
|
||||
(function test_basic_tour() {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var assert = require('assert');
|
||||
|
||||
function set_up_dependencies() {
|
||||
var _ = global._ = require('../../../../static/third/underscore/underscore.js');
|
||||
var _ = global._ = require('third/underscore/underscore.js');
|
||||
global.Handlebars = require('handlebars');
|
||||
|
||||
// We stub out most of jQuery, which is irrelevant to most of these tests.
|
||||
|
@ -21,8 +21,8 @@ function set_up_dependencies() {
|
|||
$.map = _.map;
|
||||
$.grep = _.filter;
|
||||
|
||||
var actual_narrow = require('../../../../static/js/narrow.js');
|
||||
var search = require('../../../../static/js/search.js');
|
||||
var actual_narrow = require('js/narrow.js');
|
||||
var search = require('js/search.js');
|
||||
|
||||
global.narrow = {
|
||||
parse: actual_narrow.parse,
|
||||
|
@ -39,7 +39,7 @@ function set_up_dependencies() {
|
|||
canonicalized_name: function (name) { return name; }
|
||||
};
|
||||
|
||||
global.typeahead_helper = require('../../../../static/js/typeahead_helper.js');
|
||||
global.typeahead_helper = require('js/typeahead_helper.js');
|
||||
|
||||
global.recent_subjects = {};
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
// clean up after themselves, and they should explicitly stub all
|
||||
// dependencies (except _).
|
||||
|
||||
global._ = require('../../../../static/third/underscore/underscore.js');
|
||||
var unread = require('../../../../static/js/unread.js');
|
||||
global._ = require('third/underscore/underscore.js');
|
||||
var unread = require('js/unread.js');
|
||||
var assert = require('assert');
|
||||
|
||||
var narrow = {};
|
||||
|
|
Loading…
Reference in New Issue