[chrome/nav] added tests for the exposed chrome apis
This commit is contained in:
parent
1ac4bcedab
commit
eb51627096
1 changed files with 40 additions and 0 deletions
40
src/ui/public/chrome/api/__tests__/nav.js
Normal file
40
src/ui/public/chrome/api/__tests__/nav.js
Normal 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');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue