From 4c5426c1b4a1f269019381548d0975b62a83e57d Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Wed, 15 Jan 2014 03:06:56 -0700 Subject: [PATCH] added the browser tests --- .travis.yml | 12 ++++++------ scripts/_utils.sh | 2 +- src/lib/utils.js | 2 +- test/angular_build_unit_tests.html | 7 ++++--- test/browser_build_unit_tests.html | 5 +++-- test/jquery_build_unit_tests.html | 5 +++-- test/unit/browser_test_angular_build.js | 7 ++++++- test/unit/test_utils.js | 2 +- test/utils/server/index.js | 26 ++++++++++++++++++------- 9 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4c096dfab..ee3ba1b72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,12 +10,12 @@ matrix: env: ES_RELEASE=0.90.10 ES_BRANCH=0.90 NODE_UNIT=0 - node_js: "0.10" env: ES_RELEASE=0.90.9 ES_BRANCH=0.90 NODE_UNIT=0 - # - node_js: "0.10" - # env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='chrome' - # - node_js: "0.10" - # env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='firefox' - # - node_js: "0.10" - # env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='ie' + - node_js: "0.10" + env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER=chrome + - node_js: "0.10" + env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER=firefox + - node_js: "0.10" + env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER=ie exclude: - node_js: false diff --git a/scripts/_utils.sh b/scripts/_utils.sh index 9a5f23748..5bab2af02 100644 --- a/scripts/_utils.sh +++ b/scripts/_utils.sh @@ -2,7 +2,7 @@ # Start or stop a group for travis ##### function group { - if [ $1 =~ "^start"]; then + if [ $1 =~ "^start" ]; then echo -e "\n--------- $1" else echo -e "--------- $1\n" diff --git a/src/lib/utils.js b/src/lib/utils.js index 9e572823f..8fdbe5113 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -65,7 +65,7 @@ _.each([ 'Function', 'RegExp' ], function (type) { - var check = _.bindKey(_, 'is' + type); + var check = _['is' + type]; utils['isArrayOf' + type + 's'] = function (arr) { // quick shallow check of arrays diff --git a/test/angular_build_unit_tests.html b/test/angular_build_unit_tests.html index 7348371d5..fdf9a99ce 100644 --- a/test/angular_build_unit_tests.html +++ b/test/angular_build_unit_tests.html @@ -1,3 +1,4 @@ + @@ -10,14 +11,14 @@ diff --git a/test/browser_build_unit_tests.html b/test/browser_build_unit_tests.html index 23e864967..a5757d52d 100644 --- a/test/browser_build_unit_tests.html +++ b/test/browser_build_unit_tests.html @@ -1,3 +1,4 @@ + @@ -10,8 +11,8 @@ diff --git a/test/unit/browser_test_angular_build.js b/test/unit/browser_test_angular_build.js index 0704e0723..e8d103b8b 100644 --- a/test/unit/browser_test_angular_build.js +++ b/test/unit/browser_test_angular_build.js @@ -45,7 +45,12 @@ describe('Angular esFactory', function () { it('returns a new client when it is called', function (done) { directive(function (esFactory) { return function () { - expect(esFactory({ log: null })).to.be.a(Client); + try { + var client = esFactory({ log: null }); + expect(client).to.have.keys('ping', 'transport', 'indices', 'cluster'); + } catch (e) { + return done(e); + } done(); }; }); diff --git a/test/unit/test_utils.js b/test/unit/test_utils.js index 21c1ea99c..c2defd5fe 100644 --- a/test/unit/test_utils.js +++ b/test/unit/test_utils.js @@ -25,7 +25,7 @@ describe('Utils', function () { not: Infinity }, Function: { - is: [console.error, console.log], + is: [function () {}, function () {}], }, RegExp: { is: [/.*/, new RegExp('a')], diff --git a/test/utils/server/index.js b/test/utils/server/index.js index be696a4f8..0cb8d7bda 100644 --- a/test/utils/server/index.js +++ b/test/utils/server/index.js @@ -2,6 +2,7 @@ var express = require('express'); var http = require('http'); var fs = require('fs'); var _ = require('lodash'); +var async = require('async'); var path = require('path'); var root = path.join(__dirname, '../../..'); var glob = require('glob'); @@ -15,7 +16,7 @@ var testFiles = 'test/unit/test_!(' + [ 'stream_logger', 'tracer_logger', 'transport_with_server', -].join('') + ')*'; +].join('|') + ')*'; var defaultFiles = _.map(glob.sync(testFiles), function (filename) { return path.resolve(root, filename); @@ -28,17 +29,28 @@ var aliasify = require('aliasify').configure({ configDir: root }); +var bundleQueue = async.queue(function (task, done) { + task(done); +}, 1); + + function browserBuild(name) { var files = _.union(defaultFiles, [path.resolve(root, 'test/unit/browser_test_' + name + '_build.js')]); return function (req, res, next) { - res.set('Content-Type', 'application/javascript'); + bundleQueue.push(function (done) { + res.set('Content-Type', 'application/javascript'); - var b = browserify(files); - b.transform(aliasify); - b.bundle({ - insertGlobals: true - }).pipe(res); + var b = browserify(files); + b.transform(aliasify); + var str = b.bundle({ + insertGlobals: true + }); + + str.pipe(res); + str.on('error', done); + str.on('end', done); + }); }; }