[chrome/nav] added tests for the exposed chrome apis

This commit is contained in:
spalger 2015-11-16 17:16:48 -06:00
parent 1ac4bcedab
commit eb51627096

View file

@ -0,0 +1,40 @@
import expect from 'expect.js';
import initChromeNavApi from 'ui/chrome/api/nav';
const basePath = '/someBasePath';
function getChrome(customInternals = { basePath }) {
const chrome = {};
initChromeNavApi(chrome, {
nav: [],
...customInternals,
});
return chrome;
}
describe('chrome nav apis', function () {
describe('#getBasePath()', function () {
it('returns the basePath', function () {
const chrome = getChrome();
expect(chrome.getBasePath()).to.be(basePath);
});
});
describe('#addBasePath()', function () {
it('returns undefined when nothing is passed', function () {
const chrome = getChrome();
expect(chrome.addBasePath()).to.be(undefined);
});
it('prepends the base path when the input is a path', function () {
const chrome = getChrome();
expect(chrome.addBasePath('/other/path')).to.be(`${basePath}/other/path`);
});
it('ignores non-path urls', function () {
const chrome = getChrome();
expect(chrome.addBasePath('http://github.com/elastic/kibana')).to.be('http://github.com/elastic/kibana');
});
});
});