Skip to content

Commit e413a96

Browse files
test: migrate to jest
1 parent 5a6f520 commit e413a96

File tree

14 files changed

+3498
-1499
lines changed

14 files changed

+3498
-1499
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ jobs:
7272
architecture: ${{ steps.calculate_architecture.outputs.result }}
7373
cache: "npm"
7474
- run: npm install --ignore-engines
75-
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x'
75+
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x'
7676
- run: npm ci
77-
if: matrix.node-version != '10.x' && matrix.node-version != '12.x' && matrix.node-version != '14.x' && matrix.node-version != '16.x'
77+
if: matrix.node-version != '10.x' && matrix.node-version != '12.x' && matrix.node-version != '14.x'
7878
- run: npm run test:coverage
7979
env:
8080
WATCHPACK_POLLING: ${{ matrix.polling }}

lib/DirectoryWatcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"use strict";
66

77
const { EventEmitter } = require("events");
8-
const fs = require("graceful-fs");
98
const path = require("path");
9+
const fs = require("graceful-fs");
1010

1111
const watchEventSource = require("./watchEventSource");
1212

@@ -954,5 +954,5 @@ class DirectoryWatcher extends EventEmitter {
954954
}
955955

956956
module.exports = DirectoryWatcher;
957-
module.exports.Watcher = Watcher;
958957
module.exports.EXISTANCE_ONLY_TIME_ENTRY = EXISTANCE_ONLY_TIME_ENTRY;
958+
module.exports.Watcher = Watcher;

lib/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
*/
55
"use strict";
66

7-
const getWatcherManager = require("./getWatcherManager");
8-
const LinkResolver = require("./LinkResolver");
97
const { EventEmitter } = require("events");
108
const globToRegExp = require("glob-to-regexp");
9+
const LinkResolver = require("./LinkResolver");
10+
const getWatcherManager = require("./getWatcherManager");
1111
const watchEventSource = require("./watchEventSource");
1212

1313
/** @typedef {import("./getWatcherManager").WatcherManager} WatcherManager */
1414
/** @typedef {import("./DirectoryWatcher")} DirectoryWatcher */
1515
/** @typedef {import("./DirectoryWatcher").DirectoryWatcherEvents} DirectoryWatcherEvents */
1616
/** @typedef {import("./DirectoryWatcher").FileWatcherEvents} FileWatcherEvents */
1717

18-
// eslint-disable-next-line jsdoc/no-restricted-syntax
18+
// eslint-disable-next-line jsdoc/reject-any-type
1919
/** @typedef {Record<string, (...args: any[]) => any>} EventMap */
2020

2121
/**
@@ -45,6 +45,7 @@ const watchEventSource = require("./watchEventSource");
4545
/** @typedef {`scan (${string})` | "change" | "rename" | `watch ${string}` | `directory-removed ${string}`} EventType */
4646
/** @typedef {{ safeTime: number, timestamp: number, accuracy: number }} Entry */
4747
/** @typedef {{ safeTime: number }} OnlySafeTimeEntry */
48+
// eslint-disable-next-line jsdoc/ts-no-empty-object-type
4849
/** @typedef {{}} ExistanceOnlyTimeEntry */
4950
/** @typedef {Map<string, Entry | OnlySafeTimeEntry | ExistanceOnlyTimeEntry | null>} TimeInfoEntries */
5051
/** @typedef {Set<string>} Changes */

lib/watchEventSource.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
*/
55
"use strict";
66

7+
const { EventEmitter } = require("events");
78
const fs = require("fs");
89
const path = require("path");
9-
const { EventEmitter } = require("events");
1010
const reducePlan = require("./reducePlan");
1111

1212
/** @typedef {import("fs").FSWatcher} FSWatcher */
@@ -398,10 +398,26 @@ const execute = () => {
398398
}
399399
};
400400

401+
/**
402+
* @param {() => void} fn a function
403+
*/
404+
module.exports.Watcher = Watcher;
405+
module.exports.batch = (fn) => {
406+
isBatch = true;
407+
try {
408+
fn();
409+
} finally {
410+
isBatch = false;
411+
execute();
412+
}
413+
};
414+
401415
/**
402416
* @param {string} filePath a file path
403417
* @returns {Watcher} watcher
404418
*/
419+
module.exports.createHandleChangeEvent = createHandleChangeEvent;
420+
module.exports.getNumberOfWatchers = () => watcherCount;
405421
module.exports.watch = (filePath) => {
406422
const watcher = new Watcher();
407423
// Find an existing watcher
@@ -427,20 +443,4 @@ module.exports.watch = (filePath) => {
427443
return watcher;
428444
};
429445

430-
/**
431-
* @param {() => void} fn a function
432-
*/
433-
module.exports.batch = (fn) => {
434-
isBatch = true;
435-
try {
436-
fn();
437-
} finally {
438-
isBatch = false;
439-
execute();
440-
}
441-
};
442-
443-
module.exports.getNumberOfWatchers = () => watcherCount;
444-
module.exports.createHandleChangeEvent = createHandleChangeEvent;
445446
module.exports.watcherLimit = watcherLimit;
446-
module.exports.Watcher = Watcher;

0 commit comments

Comments
 (0)