feat(auth): add selectStatusIsLoading selector to get information whether auth store status equals "loading"
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
export * from "./selectFormValid/selectFormValid";
|
||||
export * from "./selectAuthData/selectAuthData";
|
||||
export * from "./selectStatusIsLoading/selectStatusIsLoading";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useAuthStore } from "../../stores";
|
||||
import { selectStatusIsLoading } from "./selectStatusIsLoading";
|
||||
|
||||
describe("selectStatusIsLoading", () => {
|
||||
afterEach(() => {
|
||||
useAuthStore.getState().reset();
|
||||
});
|
||||
|
||||
it("should return true when status is 'loading'", () => {
|
||||
useAuthStore.setState({ status: "loading" });
|
||||
expect(selectStatusIsLoading(useAuthStore.getState())).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false when status is not 'loading'", () => {
|
||||
useAuthStore.setState({ status: "idle" });
|
||||
expect(selectStatusIsLoading(useAuthStore.getState())).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
import type { AuthStore } from "../../types/store";
|
||||
|
||||
export const selectStatusIsLoading = (state: AuthStore) =>
|
||||
state.status === "loading";
|
||||
Reference in New Issue
Block a user