2016-10-17 18:55:03 +00:00
|
|
|
import expect from 'expect';
|
|
|
|
|
|
|
|
|
|
import { calculateTooltipDirection } from './helpers';
|
|
|
|
|
|
2016-11-04 17:06:11 +00:00
|
|
|
describe('EllipsisMenu - helpers', () => {
|
2016-10-17 18:55:03 +00:00
|
|
|
describe('#calculateTooltipDirection', () => {
|
|
|
|
|
it('returns "left" if the element does not fit to the right in the browser', () => {
|
|
|
|
|
const el = {
|
|
|
|
|
getBoundingClientRect: () => {
|
|
|
|
|
return {
|
|
|
|
|
// test DOM window.innerWidth is 1024px
|
|
|
|
|
right: 725,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(calculateTooltipDirection(el)).toEqual('left');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns "right" if the element fits to the right in the browser', () => {
|
|
|
|
|
const el = {
|
|
|
|
|
getBoundingClientRect: () => {
|
|
|
|
|
return {
|
|
|
|
|
// test DOM window.innerWidth is 1024px
|
|
|
|
|
right: 724,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(calculateTooltipDirection(el)).toEqual('right');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|