2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2018-03-17 18:26:18 +05:30
|
|
|
import Todos from '~/pages/dashboard/todos/index/todos';
|
2017-09-10 17:25:29 +05:30
|
|
|
import '~/lib/utils/common_utils';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
describe('Todos', () => {
|
2019-07-07 11:18:12 +05:30
|
|
|
preloadFixtures('todos/todos.html');
|
2017-08-17 22:00:37 +05:30
|
|
|
let todoItem;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-07-07 11:18:12 +05:30
|
|
|
loadFixtures('todos/todos.html');
|
2017-08-17 22:00:37 +05:30
|
|
|
todoItem = document.querySelector('.todos-list .todo');
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
return new Todos();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('goToTodoUrl', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
it('opens the todo url', done => {
|
2017-08-17 22:00:37 +05:30
|
|
|
const todoLink = todoItem.dataset.url;
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
spyOnDependency(Todos, 'visitUrl').and.callFake(url => {
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(url).toEqual(todoLink);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
todoItem.click();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('meta click', () => {
|
|
|
|
let visitUrlSpy;
|
2018-03-17 18:26:18 +05:30
|
|
|
let windowOpenSpy;
|
|
|
|
let metakeyEvent;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2018-03-17 18:26:18 +05:30
|
|
|
metakeyEvent = $.Event('click', { keyCode: 91, ctrlKey: true });
|
2018-10-15 14:42:47 +05:30
|
|
|
visitUrlSpy = spyOnDependency(Todos, 'visitUrl').and.callFake(() => {});
|
2018-03-17 18:26:18 +05:30
|
|
|
windowOpenSpy = spyOn(window, 'open').and.callFake(() => {});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('opens the todo url in another tab', () => {
|
2017-08-17 22:00:37 +05:30
|
|
|
const todoLink = todoItem.dataset.url;
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
$('.todos-list .todo').trigger(metakeyEvent);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(visitUrlSpy).not.toHaveBeenCalled();
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(windowOpenSpy).toHaveBeenCalledWith(todoLink, '_blank');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('run native funcionality when avatar is clicked', () => {
|
|
|
|
$('.todos-list a').on('click', e => e.preventDefault());
|
|
|
|
$('.todos-list img').trigger(metakeyEvent);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(visitUrlSpy).not.toHaveBeenCalled();
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(windowOpenSpy).not.toHaveBeenCalled();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|