From 7da7df44ff354629e4df28687530f478c5a28e56 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Mon, 13 Jan 2020 06:20:54 -0800 Subject: [PATCH] Fixed tests Summary: Fixed few tests which were failing on Windows Reviewed By: mweststrate Differential Revision: D19371105 fbshipit-source-id: 118a76783680a3efa0645321d8c88b4e6e754ce0 --- src/utils/Idler.tsx | 3 ++- src/utils/__tests__/Idler.node.js | 2 +- src/utils/__tests__/icons.node.js | 17 +++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/utils/Idler.tsx b/src/utils/Idler.tsx index f7bf678aa..18be076c0 100644 --- a/src/utils/Idler.tsx +++ b/src/utils/Idler.tsx @@ -19,9 +19,10 @@ export interface BaseIdler { export class Idler implements BaseIdler { private lastIdle = performance.now(); - private interval = 16; private kill = false; + constructor(private interval = 16) {} + shouldIdle(): boolean { return this.kill || performance.now() - this.lastIdle > this.interval; } diff --git a/src/utils/__tests__/Idler.node.js b/src/utils/__tests__/Idler.node.js index d2238c25b..eff8efd1d 100644 --- a/src/utils/__tests__/Idler.node.js +++ b/src/utils/__tests__/Idler.node.js @@ -30,7 +30,7 @@ test('Idler should interrupt', async () => { }); test('Idler should want to idle', async () => { - const idler = new Idler(); + const idler = new Idler(100); expect(idler.shouldIdle()).toBe(false); await sleep(10); expect(idler.shouldIdle()).toBe(false); diff --git a/src/utils/__tests__/icons.node.js b/src/utils/__tests__/icons.node.js index d2e38e0b3..901f09695 100644 --- a/src/utils/__tests__/icons.node.js +++ b/src/utils/__tests__/icons.node.js @@ -8,27 +8,28 @@ */ import {buildLocalIconPath, buildIconURL} from '../icons'; +import * as path from 'path'; test('filled icons get correct local path', () => { - const path = buildLocalIconPath('star', 12, 2); - expect(path).toBe('icons/star-filled-12@2x.png'); + const iconPath = buildLocalIconPath('star', 12, 2); + expect(iconPath).toBe(path.join('icons', 'star-filled-12@2x.png')); }); test('outline icons get correct local path', () => { - const path = buildLocalIconPath('star-outline', 12, 2); - expect(path).toBe('icons/star-outline-12@2x.png'); + const iconPath = buildLocalIconPath('star-outline', 12, 2); + expect(iconPath).toBe(path.join('icons', 'star-outline-12@2x.png')); }); test('filled icons get correct URL', () => { - const path = buildIconURL('star', 12, 2); - expect(path).toBe( + const iconUrl = buildIconURL('star', 12, 2); + expect(iconUrl).toBe( 'https://external.xx.fbcdn.net/assets/?name=star&variant=filled&size=12&set=facebook_icons&density=2x', ); }); test('outline icons get correct URL', () => { - const path = buildIconURL('star-outline', 12, 2); - expect(path).toBe( + const iconUrl = buildIconURL('star-outline', 12, 2); + expect(iconUrl).toBe( 'https://external.xx.fbcdn.net/assets/?name=star&variant=outline&size=12&set=facebook_icons&density=2x', ); });