This converts all pure tests to Jest. This was done by first running `npx jest-codemods` with the Mocha transformation, then manually fixing any places where it hadn't automatically converted the correct thing or had missed things (mostly Sinon). This also sets up VSCode correctly for running Jest.
22 lines
607 B
TypeScript
22 lines
607 B
TypeScript
import { asyncFilter, getErrorMessage } from "../../src/pure/helpers-pure";
|
|
|
|
describe("helpers-pure", () => {
|
|
it("should filter asynchronously", async () => {
|
|
expect(await asyncFilter([1, 2, 3], (x) => Promise.resolve(x > 2))).toEqual(
|
|
[3],
|
|
);
|
|
});
|
|
|
|
it("should throw on error when filtering", async () => {
|
|
const rejects = (x: number) =>
|
|
x === 3 ? Promise.reject(new Error("opps")) : Promise.resolve(true);
|
|
|
|
try {
|
|
await asyncFilter([1, 2, 3], rejects);
|
|
fail("Should have thrown");
|
|
} catch (e) {
|
|
expect(getErrorMessage(e)).toBe("opps");
|
|
}
|
|
});
|
|
});
|