diff --git a/src/features/auth/model/selectors/index.ts b/src/features/auth/model/selectors/index.ts index f81592d..9358ad5 100644 --- a/src/features/auth/model/selectors/index.ts +++ b/src/features/auth/model/selectors/index.ts @@ -1,2 +1,3 @@ export * from "./selectFormValid/selectFormValid"; export * from "./selectAuthData/selectAuthData"; +export * from "./selectStatusIsLoading/selectStatusIsLoading"; diff --git a/src/features/auth/model/selectors/selectStatusIsLoading/selectStatusIsLoading.spec.ts b/src/features/auth/model/selectors/selectStatusIsLoading/selectStatusIsLoading.spec.ts new file mode 100644 index 0000000..495b1bd --- /dev/null +++ b/src/features/auth/model/selectors/selectStatusIsLoading/selectStatusIsLoading.spec.ts @@ -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); + }); +}); diff --git a/src/features/auth/model/selectors/selectStatusIsLoading/selectStatusIsLoading.ts b/src/features/auth/model/selectors/selectStatusIsLoading/selectStatusIsLoading.ts new file mode 100644 index 0000000..c30f6a1 --- /dev/null +++ b/src/features/auth/model/selectors/selectStatusIsLoading/selectStatusIsLoading.ts @@ -0,0 +1,4 @@ +import type { AuthStore } from "../../types/store"; + +export const selectStatusIsLoading = (state: AuthStore) => + state.status === "loading";