diff options
author | Phil Hughes <me@iamphill.com> | 2017-09-12 15:38:42 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-09-12 15:39:08 +0100 |
commit | 855c258fdbceb1e2f19f096da755b9741122d628 (patch) | |
tree | 89d03f749b9d977c59a047fb2559ffa0d0a76827 /spec | |
parent | 08362d80b8dc915c0812c32df5f8505c26b19b53 (diff) | |
download | gitlab-ce-855c258fdbceb1e2f19f096da755b9741122d628.tar.gz |
fixed todos spec
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/todos_spec.js | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/spec/javascripts/todos_spec.js b/spec/javascripts/todos_spec.js index 207ad2d6f97..7d3c9319a11 100644 --- a/spec/javascripts/todos_spec.js +++ b/spec/javascripts/todos_spec.js @@ -26,38 +26,30 @@ describe('Todos', () => { describe('meta click', () => { let visitUrlSpy; + let windowOpenSpy; let metakeyEvent; beforeEach(() => { metakeyEvent = $.Event('click', { keyCode: 91, ctrlKey: true }); visitUrlSpy = spyOn(gl.utils, 'visitUrl').and.callFake(() => {}); + windowOpenSpy = spyOn(window, 'open').and.callFake(() => {}); }); - it('opens the todo url in another tab', (done) => { + it('opens the todo url in another tab', () => { const todoLink = todoItem.dataset.url; - spyOn(window, 'open').and.callFake((url, target) => { - expect(todoLink).toEqual(url); - expect(target).toEqual('_blank'); - done(); - }); - $('.todos-list .todo').trigger(metakeyEvent); + expect(visitUrlSpy).not.toHaveBeenCalled(); + expect(windowOpenSpy).toHaveBeenCalledWith(todoLink, '_blank'); }); - it('opens the avatar\'s url in another tab when the avatar is clicked', (done) => { - const avatarImage = todoItem.querySelector('img'); - const avatarUrl = avatarImage.parentElement.getAttribute('href'); - - spyOn(window, 'open').and.callFake((url, target) => { - expect(avatarUrl).toEqual(url); - expect(target).toEqual('_blank'); - done(); - }); + it('run native funcionality when avatar is clicked', () => { + $('.todos-list a').on('click', e => e.preventDefault()); + $('.todos-list img').trigger(metakeyEvent); - avatarImage.click(); expect(visitUrlSpy).not.toHaveBeenCalled(); + expect(windowOpenSpy).not.toHaveBeenCalled(); }); }); }); |