Commit 553fb1bc authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'tz-make-user-popover-spec-more-consistent' into 'master'

Made user_popovers_spec more stable

See merge request gitlab-org/gitlab-ce!24145
parents 95920a2c d6e506dd
...@@ -30,7 +30,9 @@ describe('User Popovers', () => { ...@@ -30,7 +30,9 @@ describe('User Popovers', () => {
}); });
it('Should Show+Hide Popover on mouseenter and mouseleave', done => { it('Should Show+Hide Popover on mouseenter and mouseleave', done => {
triggerEvent('mouseenter', document.querySelector(selector)); const targetLink = document.querySelector(selector);
const { userId } = targetLink.dataset;
triggerEvent('mouseenter', targetLink);
setTimeout(() => { setTimeout(() => {
const shownPopover = document.querySelector('.popover'); const shownPopover = document.querySelector('.popover');
...@@ -38,9 +40,9 @@ describe('User Popovers', () => { ...@@ -38,9 +40,9 @@ describe('User Popovers', () => {
expect(shownPopover).not.toBeNull(); expect(shownPopover).not.toBeNull();
expect(shownPopover.innerHTML).toContain(dummyUser.name); expect(shownPopover.innerHTML).toContain(dummyUser.name);
expect(UsersCache.retrieveById).toHaveBeenCalledWith('58'); expect(UsersCache.retrieveById).toHaveBeenCalledWith(userId.toString());
triggerEvent('mouseleave', document.querySelector(selector)); triggerEvent('mouseleave', targetLink);
setTimeout(() => { setTimeout(() => {
// After Mouse leave it should be hidden now // After Mouse leave it should be hidden now
...@@ -51,13 +53,15 @@ describe('User Popovers', () => { ...@@ -51,13 +53,15 @@ describe('User Popovers', () => {
}); });
it('Should Not show a popover on short mouse over', done => { it('Should Not show a popover on short mouse over', done => {
triggerEvent('mouseenter', document.querySelector(selector)); const targetLink = document.querySelector(selector);
const { userId } = targetLink.dataset;
triggerEvent('mouseenter', targetLink);
setTimeout(() => { setTimeout(() => {
expect(document.querySelector('.popover')).toBeNull(); expect(document.querySelector('.popover')).toBeNull();
expect(UsersCache.retrieveById).not.toHaveBeenCalledWith('1'); expect(UsersCache.retrieveById).not.toHaveBeenCalledWith(userId.toString());
triggerEvent('mouseleave', document.querySelector(selector)); triggerEvent('mouseleave', targetLink);
done(); done();
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment