mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
wrap top-level tests in a describe so the beforeEach doesn't leak
This commit is contained in:
parent
c72436b49c
commit
30f3d217d3
1 changed files with 81 additions and 79 deletions
|
@ -11,93 +11,95 @@ define(function (require) {
|
|||
|
||||
describe('Custom Route Management', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
routes = new RouteManager();
|
||||
});
|
||||
|
||||
it('should have chainable methods: ' + _.pluck(chainableMethods, 'name').join(', '), function () {
|
||||
chainableMethods.forEach(function (meth) {
|
||||
expect(routes[meth.name].apply(routes, _.clone(meth.args))).to.be(routes);
|
||||
describe('top level api', function () {
|
||||
beforeEach(function () {
|
||||
routes = new RouteManager();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#otherwise', function () {
|
||||
it('should forward the last otherwise route', function () {
|
||||
var otherRoute = {};
|
||||
routes.otherwise({});
|
||||
routes.otherwise(otherRoute);
|
||||
|
||||
var exec;
|
||||
routes.config({
|
||||
otherwise: function (route) {
|
||||
expect(route).to.be(otherRoute);
|
||||
exec = true;
|
||||
}
|
||||
});
|
||||
|
||||
expect(exec).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#when', function () {
|
||||
it('should merge the additions into the when() defined routes', function () {
|
||||
routes.when('/some/route');
|
||||
routes.when('/some/other/route');
|
||||
|
||||
// add the addition resolve to every route
|
||||
routes.addResolves(/.*/, {
|
||||
addition: function () {}
|
||||
});
|
||||
|
||||
var exec = 0;
|
||||
routes.config({
|
||||
when: function (path, route) {
|
||||
exec ++;
|
||||
// every route should have the "addition" resolve
|
||||
expect(route.resolve.addition).to.be.a('function');
|
||||
}
|
||||
});
|
||||
// we expect two routes to be sent to the $routeProvider
|
||||
expect(exec).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#config', function () {
|
||||
it('should add defined routes to the global $routeProvider service in order', function () {
|
||||
var args = [
|
||||
['/one', {}],
|
||||
['/two', {}]
|
||||
];
|
||||
|
||||
args.forEach(function (a) {
|
||||
routes.when(a[0], a[1]);
|
||||
});
|
||||
|
||||
routes.config({
|
||||
when: function (path, route) {
|
||||
var a = args.shift();
|
||||
expect(path).to.be(a[0]);
|
||||
expect(route).to.be(a[1]);
|
||||
}
|
||||
it('should have chainable methods: ' + _.pluck(chainableMethods, 'name').join(', '), function () {
|
||||
chainableMethods.forEach(function (meth) {
|
||||
expect(routes[meth.name].apply(routes, _.clone(meth.args))).to.be(routes);
|
||||
});
|
||||
});
|
||||
|
||||
it('sets route.reloadOnSearch to false by default', function () {
|
||||
routes.when('/nothing-set');
|
||||
routes.when('/no-reload', { reloadOnSearch: false });
|
||||
routes.when('/always-reload', { reloadOnSearch: true });
|
||||
describe('#otherwise', function () {
|
||||
it('should forward the last otherwise route', function () {
|
||||
var otherRoute = {};
|
||||
routes.otherwise({});
|
||||
routes.otherwise(otherRoute);
|
||||
|
||||
var exec = 0;
|
||||
var exec;
|
||||
routes.config({
|
||||
otherwise: function (route) {
|
||||
expect(route).to.be(otherRoute);
|
||||
exec = true;
|
||||
}
|
||||
});
|
||||
|
||||
routes.config({
|
||||
when: function (path, route) {
|
||||
exec ++;
|
||||
// true for the one route, false for all others
|
||||
expect(route.reloadOnSearch).to.be(path === '/always-reload');
|
||||
}
|
||||
expect(exec).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#when', function () {
|
||||
it('should merge the additions into the when() defined routes', function () {
|
||||
routes.when('/some/route');
|
||||
routes.when('/some/other/route');
|
||||
|
||||
// add the addition resolve to every route
|
||||
routes.addResolves(/.*/, {
|
||||
addition: function () {}
|
||||
});
|
||||
|
||||
var exec = 0;
|
||||
routes.config({
|
||||
when: function (path, route) {
|
||||
exec ++;
|
||||
// every route should have the "addition" resolve
|
||||
expect(route.resolve.addition).to.be.a('function');
|
||||
}
|
||||
});
|
||||
// we expect two routes to be sent to the $routeProvider
|
||||
expect(exec).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#config', function () {
|
||||
it('should add defined routes to the global $routeProvider service in order', function () {
|
||||
var args = [
|
||||
['/one', {}],
|
||||
['/two', {}]
|
||||
];
|
||||
|
||||
args.forEach(function (a) {
|
||||
routes.when(a[0], a[1]);
|
||||
});
|
||||
|
||||
routes.config({
|
||||
when: function (path, route) {
|
||||
var a = args.shift();
|
||||
expect(path).to.be(a[0]);
|
||||
expect(route).to.be(a[1]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('sets route.reloadOnSearch to false by default', function () {
|
||||
routes.when('/nothing-set');
|
||||
routes.when('/no-reload', { reloadOnSearch: false });
|
||||
routes.when('/always-reload', { reloadOnSearch: true });
|
||||
|
||||
var exec = 0;
|
||||
|
||||
routes.config({
|
||||
when: function (path, route) {
|
||||
exec ++;
|
||||
// true for the one route, false for all others
|
||||
expect(route.reloadOnSearch).to.be(path === '/always-reload');
|
||||
}
|
||||
});
|
||||
// we expect two routes to be sent to the $routeProvider
|
||||
expect(exec).to.be(3);
|
||||
});
|
||||
// we expect two routes to be sent to the $routeProvider
|
||||
expect(exec).to.be(3);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue