Files
flipper/src/utils/__tests__/Idler.node.js
Pascal Hartig 1b99e8b830 Migrate Idler
Summary: _typescript_

Reviewed By: danielbuechele

Differential Revision: D16763946

fbshipit-source-id: 96eb0cdaca8a6cd731a6d16f3bea02471c691c01
2019-08-13 08:26:54 -07:00

25 lines
515 B
JavaScript

/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
*/
import {Idler} from '../Idler.tsx';
test('Idler should interrupt', async () => {
const idler = new Idler();
let i = 0;
try {
for (; i < 500; i++) {
if (i == 100) {
idler.cancel();
}
await idler.idle();
}
expect('error').toBe('thrown');
} catch (e) {
expect(i).toEqual(100);
}
});