Skip to content

Commit

Permalink
fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Nov 12, 2024
1 parent 8aa4244 commit 9d89ecb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/__tests__/async-behavior.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// src/__tests__/async-behavior.test.ts

import { times } from "../array.js";
import { TimeoutError } from "../async.js";
import { delay, TimeoutError } from "../async.js";
import { defer } from "../defer.js";
import {
ExcludedMountPointGlobsDefault,
Expand Down Expand Up @@ -88,8 +88,9 @@ describe("Filesystem API Async Behavior", () => {
// sometimes thenOrTimeout() fails to reject in time
jest.retryTimes(5);
});
afterEach(() => {
afterEach(async () => {
jest.retryTimes(0);
await delay(500);
});
it("getVolumeMountPoints() should reject with timeoutMs=1", async () => {
await expect(getVolumeMountPoints({ timeoutMs: 1 })).rejects.toThrow(
Expand Down
8 changes: 7 additions & 1 deletion src/__tests__/unix.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// src/__tests__/unix.test.ts

import { sortByStr } from "../array.js";
import {
ExcludedMountPointGlobsDefault,
getVolumeMetadata,
Expand Down Expand Up @@ -74,7 +75,7 @@ describePlatform("linux", "darwin")(

it("should return sorted mount points", async () => {
const mountPoints = await getVolumeMountPoints();
const sorted = [...mountPoints].sort();
const sorted = sortByStr([...mountPoints], (ea) => ea);
expect(mountPoints).toEqual(sorted);
});
});
Expand Down Expand Up @@ -199,6 +200,11 @@ describePlatform("linux", "darwin")(
...ExcludedMountPointGlobsDefault,
"/init",
"/boot",
// Avoid: "/System/Volumes/Data", "/System/Volumes/Data/home",
// "/System/Volumes/Hardware", "/System/Volumes/Preboot",
// "/System/Volumes/Update", "/System/Volumes/VM",
// "/System/Volumes/iSCPreboot", "/System/Volumes/xarts",
"/System/**",
],
});
const arr = await Promise.all(
Expand Down
9 changes: 9 additions & 0 deletions src/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,12 @@ export function thenOrTimeout<T>(
timeoutPromise,
]);
}

/**
* Delay for the specified number of milliseconds.
*
* @param ms The number of milliseconds to delay
*/
export async function delay(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

0 comments on commit 9d89ecb

Please sign in to comment.