Skip to content

Commit

Permalink
no more babel
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Oct 2, 2023
1 parent 1bb780a commit fc87d85
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/useSelector.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { mockReactRedux } from "./index.js";
import { describe, it } from "@jest/globals";
import { useSelector } from "react-redux";

import { mockReactRedux } from "./index.js";

type TestState = {
value: string;
};
Expand All @@ -9,23 +11,23 @@ const selectTestValue = (state: TestState) => state.value;

describe("useSelector", () => {
it("throws an error when mockReactRedux was not previously called", () => {
expect(() => useSelector(selectTestValue)).toThrowError(
expect(() => useSelector(selectTestValue)).toThrow(
`You imported mock-react-redux but didn't call mockReactRedux() before calling useSelector from react-redux.`,
);
});

it("throws an error when a named selector has not been given a return or mock and mock state has not been set", () => {
mockReactRedux();

expect(() => useSelector(selectTestValue)).toThrowError(
expect(() => useSelector(selectTestValue)).toThrow(
`No Redux state or mock defined for 'selectTestValue'`,
);
});

it("throws an error when an anonymous selector has not been given a return or mock and mock state has not been set", () => {
mockReactRedux();

expect(() => useSelector(() => true)).toThrowError(
expect(() => useSelector(() => true)).toThrow(
`No Redux state or mock defined for '() => true'`,
);
});
Expand Down Expand Up @@ -68,7 +70,7 @@ describe("useSelector", () => {

give(selectTestValue, "");

expect(() => give(selectTestValue, "")).toThrowError(
expect(() => give(selectTestValue, "")).toThrow(
"Attempted to provide a second mock for 'selectTestValue'",
);
});
Expand All @@ -82,7 +84,7 @@ describe("useSelector", () => {

give(selector, "");

expect(() => give(selector, "")).toThrowError(
expect(() => give(selector, "")).toThrow(
`Attempted to provide a second mock for '() => ""'`,
);
});
Expand Down Expand Up @@ -125,7 +127,7 @@ describe("useSelector", () => {
jest.fn(() => ""),
);

expect(() => giveMock(selectTestValue, jest.fn())).toThrowError(
expect(() => giveMock(selectTestValue, jest.fn())).toThrow(
"Attempted to provide a second mock for 'selectTestValue'",
);
});
Expand Down

0 comments on commit fc87d85

Please sign in to comment.