added the browser tests

This commit is contained in:
Spencer Alger
2014-01-15 03:06:56 -07:00
parent 7b967617b5
commit 4c5426c1b4
9 changed files with 44 additions and 24 deletions

View File

@ -10,12 +10,12 @@ matrix:
env: ES_RELEASE=0.90.10 ES_BRANCH=0.90 NODE_UNIT=0 env: ES_RELEASE=0.90.10 ES_BRANCH=0.90 NODE_UNIT=0
- node_js: "0.10" - node_js: "0.10"
env: ES_RELEASE=0.90.9 ES_BRANCH=0.90 NODE_UNIT=0 env: ES_RELEASE=0.90.9 ES_BRANCH=0.90 NODE_UNIT=0
# - node_js: "0.10" - node_js: "0.10"
# env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='chrome' env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER=chrome
# - node_js: "0.10" - node_js: "0.10"
# env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='firefox' env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER=firefox
# - node_js: "0.10" - node_js: "0.10"
# env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='ie' env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER=ie
exclude: exclude:
- node_js: false - node_js: false

View File

@ -65,7 +65,7 @@ _.each([
'Function', 'Function',
'RegExp' 'RegExp'
], function (type) { ], function (type) {
var check = _.bindKey(_, 'is' + type); var check = _['is' + type];
utils['isArrayOf' + type + 's'] = function (arr) { utils['isArrayOf' + type + 's'] = function (arr) {
// quick shallow check of arrays // quick shallow check of arrays

View File

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
@ -10,14 +11,14 @@
<script src="mocha.js"></script> <script src="mocha.js"></script>
<script> <script>
mocha.setup('bdd'); mocha.setup('bdd');
mocha.checkLeaks(); // mocha.checkLeaks();
mocha.globals(['mochaRunner', 'angular']); // mocha.globals(['mochaRunner', 'angular']);
</script> </script>
<script src="angular.js"></script> <script src="angular.js"></script>
<script src="angular_build.js"></script> <script src="angular_build.js"></script>
<script> <script>
mocha.run().on('end', function(){ mocha.run().on('end', function(){
window.mochaResults = runner.stats; window.mochaResults = this.stats;
}); });
</script> </script>
</body> </body>

View File

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
@ -10,8 +11,8 @@
<script src="mocha.js"></script> <script src="mocha.js"></script>
<script> <script>
mocha.setup('bdd'); mocha.setup('bdd');
mocha.checkLeaks(); // mocha.checkLeaks();
mocha.globals(['mochaRunner', 'elasticsearch']); // mocha.globals(['mochaRunner', 'elasticsearch']);
</script> </script>
<script src="browser_build.js"></script> <script src="browser_build.js"></script>
<script> <script>

View File

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
@ -10,8 +11,8 @@
<script src="mocha.js"></script> <script src="mocha.js"></script>
<script> <script>
mocha.setup('bdd'); mocha.setup('bdd');
mocha.checkLeaks(); // mocha.checkLeaks();
mocha.globals(['mochaRunner', 'jQuery']); // mocha.globals(['mochaRunner', 'jQuery']);
</script> </script>
<script src="jquery.js"></script> <script src="jquery.js"></script>
<script src="jquery_build.js"></script> <script src="jquery_build.js"></script>

View File

@ -45,7 +45,12 @@ describe('Angular esFactory', function () {
it('returns a new client when it is called', function (done) { it('returns a new client when it is called', function (done) {
directive(function (esFactory) { directive(function (esFactory) {
return function () { 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(); done();
}; };
}); });

View File

@ -25,7 +25,7 @@ describe('Utils', function () {
not: Infinity not: Infinity
}, },
Function: { Function: {
is: [console.error, console.log], is: [function () {}, function () {}],
}, },
RegExp: { RegExp: {
is: [/.*/, new RegExp('a')], is: [/.*/, new RegExp('a')],

View File

@ -2,6 +2,7 @@ var express = require('express');
var http = require('http'); var http = require('http');
var fs = require('fs'); var fs = require('fs');
var _ = require('lodash'); var _ = require('lodash');
var async = require('async');
var path = require('path'); var path = require('path');
var root = path.join(__dirname, '../../..'); var root = path.join(__dirname, '../../..');
var glob = require('glob'); var glob = require('glob');
@ -15,7 +16,7 @@ var testFiles = 'test/unit/test_!(' + [
'stream_logger', 'stream_logger',
'tracer_logger', 'tracer_logger',
'transport_with_server', 'transport_with_server',
].join('') + ')*'; ].join('|') + ')*';
var defaultFiles = _.map(glob.sync(testFiles), function (filename) { var defaultFiles = _.map(glob.sync(testFiles), function (filename) {
return path.resolve(root, filename); return path.resolve(root, filename);
@ -28,17 +29,28 @@ var aliasify = require('aliasify').configure({
configDir: root configDir: root
}); });
var bundleQueue = async.queue(function (task, done) {
task(done);
}, 1);
function browserBuild(name) { function browserBuild(name) {
var files = _.union(defaultFiles, [path.resolve(root, 'test/unit/browser_test_' + name + '_build.js')]); var files = _.union(defaultFiles, [path.resolve(root, 'test/unit/browser_test_' + name + '_build.js')]);
return function (req, res, next) { return function (req, res, next) {
bundleQueue.push(function (done) {
res.set('Content-Type', 'application/javascript'); res.set('Content-Type', 'application/javascript');
var b = browserify(files); var b = browserify(files);
b.transform(aliasify); b.transform(aliasify);
b.bundle({ var str = b.bundle({
insertGlobals: true insertGlobals: true
}).pipe(res); });
str.pipe(res);
str.on('error', done);
str.on('end', done);
});
}; };
} }