fixed some doc issues, and reorganized the browser tests. Rather than running one per build, now a unit test page is run, and a build test page is run
This commit is contained in:
@ -11,13 +11,24 @@
|
||||
<script src="mocha.js"></script>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
// sauce labs & selenium inject global variables that break this
|
||||
// mocha.checkLeaks();
|
||||
// mocha.globals(['mochaRunner', 'elasticsearch']);
|
||||
// mocha.globals(['mochaRunner', 'angular']);
|
||||
</script>
|
||||
<script src="browser_build.js"></script>
|
||||
<!-- libs -->
|
||||
<script src="jquery.js"></script>
|
||||
<script src="angular.js"></script>
|
||||
|
||||
<!-- builds -->
|
||||
<script src="elasticsearch.js"></script>
|
||||
<script src="elasticsearch.angular.js"></script>
|
||||
<script src="elasticsearch.jquery.js"></script>
|
||||
|
||||
<!-- tests -->
|
||||
<script src="build_tests.js"></script>
|
||||
<script>
|
||||
mocha.run().on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
window.mochaResults = this.stats;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@ -11,11 +11,11 @@
|
||||
<script src="mocha.js"></script>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
// sauce labs & selenium inject global variables that break this
|
||||
// mocha.checkLeaks();
|
||||
// mocha.globals(['mochaRunner', 'angular']);
|
||||
</script>
|
||||
<script src="angular.js"></script>
|
||||
<script src="angular_build.js"></script>
|
||||
<script src="unit_tests.js"></script>
|
||||
<script>
|
||||
mocha.run().on('end', function(){
|
||||
window.mochaResults = this.stats;
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mocha Tests</title>
|
||||
<link rel="stylesheet" href="mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="expect.js"></script>
|
||||
<script src="mocha.js"></script>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
// mocha.checkLeaks();
|
||||
// mocha.globals(['mochaRunner', 'jQuery']);
|
||||
</script>
|
||||
<script src="jquery.js"></script>
|
||||
<script src="jquery_build.js"></script>
|
||||
<script>
|
||||
mocha.run().on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -2,11 +2,10 @@
|
||||
/* global angular */
|
||||
|
||||
var expect = require('expect.js');
|
||||
var Client = require('../../src/lib/client');
|
||||
|
||||
describe('Angular esFactory', function () {
|
||||
before(function () {
|
||||
require('../../src/elasticsearch.angular.js');
|
||||
require('../../../src/elasticsearch.angular.js');
|
||||
});
|
||||
|
||||
var uuid = (function () { var i = 0; return function () { return ++i; }; }());
|
||||
@ -46,8 +45,9 @@ describe('Angular esFactory', function () {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
try {
|
||||
var client = esFactory({ log: null });
|
||||
var client = esFactory({ hosts: null });
|
||||
expect(client).to.have.keys('ping', 'transport', 'indices', 'cluster');
|
||||
client.close();
|
||||
} catch (e) {
|
||||
return done(e);
|
||||
}
|
||||
@ -11,7 +11,7 @@ describe('elasticsearch namespace', function () {
|
||||
});
|
||||
it('can create a client', function () {
|
||||
var client = new es.Client({ hosts: null });
|
||||
expect(client).to.be.a(es.Client);
|
||||
expect(client).to.have.keys('ping', 'transport', 'indices', 'cluster');
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
@ -12,7 +12,7 @@ describe('jQuery.es namespace', function () {
|
||||
});
|
||||
it('can create a client', function () {
|
||||
var client = new $.es.Client({ hosts: null });
|
||||
expect(client).to.be.a($.es.Client);
|
||||
expect(client).to.have.keys('ping', 'transport', 'indices', 'cluster');
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
@ -8,20 +8,28 @@ var root = path.join(__dirname, '../../..');
|
||||
var glob = require('glob');
|
||||
var browserify = require('browserify');
|
||||
var pkg = require(root + '/package.json');
|
||||
var testFiles = 'test/unit/test_!(' + [
|
||||
'file_logger',
|
||||
'http_connector',
|
||||
'stdio_logger',
|
||||
'console_logger',
|
||||
'stream_logger',
|
||||
'tracer_logger',
|
||||
'transport_with_server',
|
||||
].join('|') + ')*';
|
||||
|
||||
var defaultFiles = _.map(glob.sync(testFiles), function (filename) {
|
||||
return path.resolve(root, filename);
|
||||
});
|
||||
var testFiles = {
|
||||
unit: 'test/unit/test_!(' + [
|
||||
'file_logger',
|
||||
'http_connector',
|
||||
'stdio_logger',
|
||||
'console_logger',
|
||||
'stream_logger',
|
||||
'tracer_logger',
|
||||
'transport_with_server',
|
||||
].join('|') + ')*',
|
||||
build: 'test/unit/browser_builds/*.js'
|
||||
};
|
||||
|
||||
// resolve the test file globs
|
||||
_.transform(testFiles, function (out, pattern, name) {
|
||||
out[name] = _.map(glob.sync(pattern), function (filename) {
|
||||
return path.resolve(root, filename);
|
||||
});
|
||||
}, testFiles);
|
||||
|
||||
// generic aliasify instance
|
||||
var aliasify = require('aliasify').configure({
|
||||
aliases: pkg.browser,
|
||||
excludeExtensions: 'json',
|
||||
@ -29,31 +37,31 @@ var aliasify = require('aliasify').configure({
|
||||
configDir: root
|
||||
});
|
||||
|
||||
// queue for bundle requests, two at a time
|
||||
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')]);
|
||||
}, 2);
|
||||
|
||||
// create a route that bundles a file list, based on the patterns defined in testFiles
|
||||
function bundleTests(name) {
|
||||
return function (req, res, next) {
|
||||
bundleQueue.push(function (done) {
|
||||
res.set('Content-Type', 'application/javascript');
|
||||
|
||||
var b = browserify(files);
|
||||
var b = browserify(testFiles[name]);
|
||||
b.transform(aliasify);
|
||||
var str = b.bundle({
|
||||
insertGlobals: true
|
||||
});
|
||||
|
||||
str.pipe(res);
|
||||
str.on('error', done);
|
||||
str.on('end', done);
|
||||
str.once('end', done);
|
||||
str.once('error', done);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// create a route that just rends a specific file (like a symlink or something)
|
||||
function sendFile(file) {
|
||||
return function (req, res, next) {
|
||||
res.sendfile(file);
|
||||
@ -66,9 +74,8 @@ app
|
||||
.use(express.logger('dev'))
|
||||
.use(app.router)
|
||||
// runners
|
||||
.get('/browser.html', sendFile(root + '/test/angular_build_unit_tests.html'))
|
||||
.get('/jquery.html', sendFile(root + '/test/angular_build_unit_tests.html'))
|
||||
.get('/angular.html', sendFile(root + '/test/angular_build_unit_tests.html'))
|
||||
.get('/unit.html', sendFile(root + '/test/browser_unit_tests.html'))
|
||||
.get('/builds.html', sendFile(root + '/test/browser_build_unit_tests.html'))
|
||||
|
||||
// support
|
||||
.get('/expect.js', sendFile(root + '/node_modules/expect.js/expect.js'))
|
||||
@ -79,10 +86,16 @@ app
|
||||
.get('/angular.js', sendFile(root + '/test/utils/angular.js'))
|
||||
.get('/jquery.js', sendFile(root + '/test/utils/jquery.js'))
|
||||
|
||||
// builds
|
||||
.get('/elasticsearch.js', sendFile(root + '/dist/elasticsearch.js'))
|
||||
.get('/elasticsearch.angular.js', sendFile(root + '/dist/elasticsearch.angular.js'))
|
||||
.get('/elasticsearch.jquery.js', sendFile(root + '/dist/elasticsearch.jquery.js'))
|
||||
|
||||
// bundles
|
||||
.get('/angular_build.js', browserBuild('angular'))
|
||||
.get('/jquery_build.js', browserBuild('jquery'))
|
||||
.get('/browser_build.js', browserBuild('browser'));
|
||||
.get('/unit_tests.js', bundleTests('unit'))
|
||||
.get('/build_tests.js', bundleTests('build'))
|
||||
|
||||
;
|
||||
|
||||
http.createServer(app).listen(8000, function () {
|
||||
console.log('listening on port 8000');
|
||||
|
||||
Reference in New Issue
Block a user