added browser tests, modified ci script, removed testing for version 0.90.x

This commit is contained in:
Spencer Alger
2014-01-10 11:23:08 -07:00
parent 3490479eee
commit 3223fb4a6d
20 changed files with 194 additions and 91 deletions

View File

@ -8,10 +8,13 @@
<div id="mocha"></div>
<script src="expect.js"></script>
<script src="mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script>mocha.checkLeaks();</script>
<script>
mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['mochaRunner']);
</script>
<script src="angular.js"></script>
<script src="angular_build.js"></script>
<script src="begin!"></script>
<script>var mochaRunner = mocha.run();</script>
</body>
</html>

View File

@ -8,10 +8,12 @@
<div id="mocha"></div>
<script src="expect.js"></script>
<script src="mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script>mocha.checkLeaks();</script>
<script src="angular.js"></script>
<script src="angular_build.js"></script>
<script src="begin!"></script>
<script>
mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['mochaRunner', 'elasticsearch']);
</script>
<script src="browser_build.js"></script>
<script>var mochaRunner = mocha.run();</script>
</body>
</html>

View File

@ -117,24 +117,34 @@ function YamlDoc(doc, file) {
expect(method).to.be.a('function');
if (_.isPlainObject(action.args)) {
action.name += ' ' + _.keys(action.args).join(', ');
action.name += '(' + JSON.stringify(action.args) + ')';
} else if (action.args) {
action.name += ' ' + action.args;
action.name += '(' + action.args + ')';
}
// wrap in a check for skipping
action.bound = _.bind(method, self, action.args);
// create a function that can be passed to
// create a function that can be passed to mocha or async
action.testable = function (done) {
if (self.skipping || self.file.skipping) {
return done();
}
if (method.length > 1) {
action.bound(done);
action.bound(function (err) {
if (err) {
err.message += ' in ' + action.name;
}
done(err);
});
} else {
action.bound();
done();
try {
action.bound();
done();
} catch (err) {
err.message += ' in ' + action.name;
done(err);
}
}
};

View File

@ -8,10 +8,13 @@
<div id="mocha"></div>
<script src="expect.js"></script>
<script src="mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script>mocha.checkLeaks();</script>
<script src="angular.js"></script>
<script src="angular_build.js"></script>
<script src="begin!"></script>
<script>
mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['mochaRunner', 'jQuery']);
</script>
<script src="jquery.js"></script>
<script src="jquery_build.js"></script>
<script>var mochaRunner = mocha.run();</script>
</body>
</html>

View File

@ -0,0 +1,17 @@
/* jshint browser:true */
var expect = require('expect.js');
describe('elasticsearch namespace', function () {
var es = window.elasticsearch;
it('is defined on the window', function () {
expect(es).to.be.ok();
});
it('has Client, ConnectionPool, Transport, and errors keys', function () {
expect(es).to.have.keys('Client', 'ConnectionPool', 'Transport', 'errors');
});
it('can create a client', function () {
var client = new es.Client({ hosts: null });
expect(client).to.be.a(es.Client);
client.close();
});
});

View File

@ -0,0 +1,18 @@
/* jshint browser:true */
var expect = require('expect.js');
describe('jQuery.es namespace', function () {
var $ = window.jQuery;
it('is defined on the global jQuery', function () {
expect($.es).to.be.ok();
});
it('has Client, ConnectionPool, Transport, and errors keys', function () {
expect($.es).to.have.keys('Client', 'ConnectionPool', 'Transport', 'errors');
});
it('can create a client', function () {
var client = new $.es.Client({ hosts: null });
expect(client).to.be.a($.es.Client);
client.close();
});
});

View File

@ -98,7 +98,7 @@ describe('Client Action runner', function () {
it('handles passing just the callback', function () {
var action = makeClientActionProxy(function (params, cb) {
expect(_.isObject(params)).to.be.ok;
expect(_.isObject(params)).to.be.ok();
expect(cb).to.be.a('function');
});

View File

@ -479,6 +479,7 @@ describe('Transport Class', function () {
expect(err).to.be.a(errors.ConnectionFault);
expect(resp).to.be(undefined);
expect(body).to.be(undefined);
trans.close();
done();
});
};

View File

@ -11,7 +11,6 @@ var pkg = require(root + '/package.json');
var defaultFiles = _.transform(pkg.testling.files, function (files, pattern) {
[].push.apply(files, _.map(glob.sync(pattern), function (filename) {
console.log('resolving', filename);
return path.resolve(root, filename);
}));
}, []);
@ -25,7 +24,6 @@ var aliasify = require('aliasify').configure({
function browserBuild(name) {
return function (req, res, next) {
res.set('Content-Type', 'application/javascript');
var b = browserify(_.union(defaultFiles, [
@ -66,23 +64,7 @@ app
// bundles
.get('/angular_build.js', browserBuild('angular'))
.get('/jquery_build.js', browserBuild('jquery'))
.get('/browser_build.js', browserBuild('browser'))
// stupid
.get('/begin!', function (req, res) {
res.set('Content-Type', 'application/javascript');
res.send([
'mocha.run().on(\'end\', function () {',
' var stats = window.completeTestStats = {};',
' for (var key in this.stats) {',
' if (this.stats.hasOwnProperty(key)) {',
' stats[key] = this.stats[key];',
' }',
' }',
' console && console.dir && console.dir(window.completeTestStats);',
'});'
].join('\n'));
});
.get('/browser_build.js', browserBuild('browser'));
http.createServer(app).listen(8000, function () {
console.log('listening on port 8000');