feat(auth): add selectStatusIsLoading selector to get information whether auth store status equals "loading"

This commit is contained in:
Ilia Mashkov
2026-03-24 19:57:27 +03:00
parent e4630a7fcb
commit c006a94c4d
3 changed files with 23 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
export * from "./selectFormValid/selectFormValid"; export * from "./selectFormValid/selectFormValid";
export * from "./selectAuthData/selectAuthData"; export * from "./selectAuthData/selectAuthData";
export * from "./selectStatusIsLoading/selectStatusIsLoading";

View File

@@ -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);
});
});

View File

@@ -0,0 +1,4 @@
import type { AuthStore } from "../../types/store";
export const selectStatusIsLoading = (state: AuthStore) =>
state.status === "loading";