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:
58
test/unit/browser_builds/angular.js
vendored
Normal file
58
test/unit/browser_builds/angular.js
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
/* jshint browser:true */
|
||||
/* global angular */
|
||||
|
||||
var expect = require('expect.js');
|
||||
|
||||
describe('Angular esFactory', function () {
|
||||
before(function () {
|
||||
require('../../../src/elasticsearch.angular.js');
|
||||
});
|
||||
|
||||
var uuid = (function () { var i = 0; return function () { return ++i; }; }());
|
||||
function directive(makeDirective) {
|
||||
var root = document.createElement('div');
|
||||
var id = uuid();
|
||||
root.setAttribute('test-directive-' + id, 'test-directive');
|
||||
document.body.appendChild(root);
|
||||
|
||||
after(function () {
|
||||
document.body.removeChild(root);
|
||||
root = null;
|
||||
});
|
||||
|
||||
angular.module('mod' + id, ['elasticsearch']).directive('testDirective' + id, makeDirective);
|
||||
angular.bootstrap(root, ['mod' + id]);
|
||||
}
|
||||
|
||||
it('is available in the elasticsearch module', function (done) {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
expect(esFactory).to.be.a('function');
|
||||
done();
|
||||
};
|
||||
});
|
||||
});
|
||||
it('has Transport and ConnectionPool properties', function (done) {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
expect(esFactory).to.have.property('Transport');
|
||||
expect(esFactory).to.have.property('ConnectionPool');
|
||||
done();
|
||||
};
|
||||
});
|
||||
});
|
||||
it('returns a new client when it is called', function (done) {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
try {
|
||||
var client = esFactory({ hosts: null });
|
||||
expect(client).to.have.keys('ping', 'transport', 'indices', 'cluster');
|
||||
client.close();
|
||||
} catch (e) {
|
||||
return done(e);
|
||||
}
|
||||
done();
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
17
test/unit/browser_builds/generic.js
Normal file
17
test/unit/browser_builds/generic.js
Normal 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.have.keys('ping', 'transport', 'indices', 'cluster');
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
18
test/unit/browser_builds/jquery.js
vendored
Normal file
18
test/unit/browser_builds/jquery.js
vendored
Normal 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.have.keys('ping', 'transport', 'indices', 'cluster');
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user