ohif-viewer/src/utils/getDefaultToolbarButtons.test.js

27 lines
844 B
JavaScript
Raw Normal View History

2019-05-29 14:39:54 +02:00
import getDefaultToolbarButtons from './getDefaultToolbarButtons.js';
2019-05-01 19:07:43 +02:00
describe('getDefaultToolbarButtons.js', () => {
it('returns a non-empty array', () => {
2019-05-29 14:39:54 +02:00
const basePath = '/';
2019-05-01 19:07:43 +02:00
2019-05-29 14:39:54 +02:00
const buttons = getDefaultToolbarButtons(basePath);
2019-05-01 19:07:43 +02:00
2019-05-29 14:39:54 +02:00
expect(buttons.length).toBeGreaterThan(0);
});
2019-05-01 19:07:43 +02:00
it('uses the provided basePath in buttons with an svgUrl property', () => {
2019-05-29 14:39:54 +02:00
const basePath = '/demo/';
2019-05-01 19:07:43 +02:00
2019-05-29 14:39:54 +02:00
const buttons = getDefaultToolbarButtons(basePath);
2019-05-01 19:07:43 +02:00
const hasOneOrMoreButtonsWithSvgUrlProperty = buttons.some(btn =>
btn.hasOwnProperty('svgUrl')
2019-05-29 14:39:54 +02:00
);
2019-05-01 19:07:43 +02:00
const usesBasePathInButtonSvgUrls = buttons.every(
btn => !btn.hasOwnProperty('svgUrl') || btn.svgUrl.includes(basePath)
2019-05-29 14:39:54 +02:00
);
2019-05-01 19:07:43 +02:00
2019-05-29 14:39:54 +02:00
expect(hasOneOrMoreButtonsWithSvgUrlProperty).toBeTruthy();
expect(usesBasePathInButtonSvgUrls).toBeTruthy();
});
});