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

Restore `sinon.useFakeTimers()`

parent d70da1e3
......@@ -183,15 +183,19 @@ describe('Menu', () => {
shouldClose ? 'closes' : "doesn't close"
} when user performs a "${eventType}" (key: "${key}") on menu content`, () => {
clock = sinon.useFakeTimers();
const wrapper = createMenu({ defaultOpen: true });
wrapper.find('.Menu__content').simulate(eventType, { key });
// The close event is delayed by a minimal amount of time in
// order to allow links to say in the DOM long enough to be
// followed on a click. Therefore, this test must simulate
// time passing in order for the menu to close.
clock.tick(1);
wrapper.update();
assert.equal(isOpen(wrapper), !shouldClose);
try {
const wrapper = createMenu({ defaultOpen: true });
wrapper.find('.Menu__content').simulate(eventType, { key });
// The close event is delayed by a minimal amount of time in
// order to allow links to say in the DOM long enough to be
// followed on a click. Therefore, this test must simulate
// time passing in order for the menu to close.
clock.tick(1);
wrapper.update();
assert.equal(isOpen(wrapper), !shouldClose);
} finally {
clock.restore();
}
});
});
......
......@@ -70,7 +70,6 @@ describe('MenuKeyboardNavigation', () => {
});
it('sets focus to the first `menuitem` child when `visible` is true', () => {
const clock = sinon.useFakeTimers();
createMenuItem({ visible: true });
clock.tick(1);
assert.equal(document.activeElement.innerText, 'Item 1');
......
......@@ -148,18 +148,21 @@ describe('sidebar/util/postmessage-json-rpc', () => {
it('if timeout is null, then it does not timeout', async () => {
const clock = sinon.useFakeTimers();
const result = doCall(null);
clock.tick(100000); // wait a long time
fakeWindow.emitter.emit('message', {
origin,
data: {
jsonrpc: '2.0',
id: messageId,
result: {},
},
});
await result;
clock.restore();
try {
const result = doCall(null);
clock.tick(100000); // wait a long time
fakeWindow.emitter.emit('message', {
origin,
data: {
jsonrpc: '2.0',
id: messageId,
result: {},
},
});
await result;
} finally {
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