Commit 7c2ddbb7 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Restore `sinon.useFakeTimers()`

parent d70da1e3
...@@ -183,6 +183,7 @@ describe('Menu', () => { ...@@ -183,6 +183,7 @@ describe('Menu', () => {
shouldClose ? 'closes' : "doesn't close" shouldClose ? 'closes' : "doesn't close"
} when user performs a "${eventType}" (key: "${key}") on menu content`, () => { } when user performs a "${eventType}" (key: "${key}") on menu content`, () => {
clock = sinon.useFakeTimers(); clock = sinon.useFakeTimers();
try {
const wrapper = createMenu({ defaultOpen: true }); const wrapper = createMenu({ defaultOpen: true });
wrapper.find('.Menu__content').simulate(eventType, { key }); wrapper.find('.Menu__content').simulate(eventType, { key });
// The close event is delayed by a minimal amount of time in // The close event is delayed by a minimal amount of time in
...@@ -192,6 +193,9 @@ describe('Menu', () => { ...@@ -192,6 +193,9 @@ describe('Menu', () => {
clock.tick(1); clock.tick(1);
wrapper.update(); wrapper.update();
assert.equal(isOpen(wrapper), !shouldClose); assert.equal(isOpen(wrapper), !shouldClose);
} finally {
clock.restore();
}
}); });
}); });
......
...@@ -70,7 +70,6 @@ describe('MenuKeyboardNavigation', () => { ...@@ -70,7 +70,6 @@ describe('MenuKeyboardNavigation', () => {
}); });
it('sets focus to the first `menuitem` child when `visible` is true', () => { it('sets focus to the first `menuitem` child when `visible` is true', () => {
const clock = sinon.useFakeTimers();
createMenuItem({ visible: true }); createMenuItem({ visible: true });
clock.tick(1); clock.tick(1);
assert.equal(document.activeElement.innerText, 'Item 1'); assert.equal(document.activeElement.innerText, 'Item 1');
......
...@@ -148,6 +148,7 @@ describe('sidebar/util/postmessage-json-rpc', () => { ...@@ -148,6 +148,7 @@ describe('sidebar/util/postmessage-json-rpc', () => {
it('if timeout is null, then it does not timeout', async () => { it('if timeout is null, then it does not timeout', async () => {
const clock = sinon.useFakeTimers(); const clock = sinon.useFakeTimers();
try {
const result = doCall(null); const result = doCall(null);
clock.tick(100000); // wait a long time clock.tick(100000); // wait a long time
fakeWindow.emitter.emit('message', { fakeWindow.emitter.emit('message', {
...@@ -159,7 +160,9 @@ describe('sidebar/util/postmessage-json-rpc', () => { ...@@ -159,7 +160,9 @@ describe('sidebar/util/postmessage-json-rpc', () => {
}, },
}); });
await result; await result;
} finally {
clock.restore(); clock.restore();
}
}); });
}); });
}); });
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