Skip to content

Commit

Permalink
fix: improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-mazz committed Feb 13, 2025
1 parent 2b801f6 commit ac82e91
Showing 1 changed file with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
itwIsFeedbackBannerHiddenSelector,
itwRequestedCredentialsSelector
} from "../preferences";
import { ItwAuthLevel } from "../../../utils/itwTypesUtils.ts";

describe("itwIsFeedbackBannerHiddenSelector", () => {
it.each([
Expand Down Expand Up @@ -73,16 +74,46 @@ describe("itwRequestedCredentialsSelector", () => {
});

describe("itwAuthLevelSelector", () => {
it("should return the auth level used when issuing the eid", () => {
const globalState = appReducer(undefined, applicationChangeState("active"));

expect(
itwAuthLevelSelector(
_.set(globalState, "features.itWallet.preferences", {
authLevel: "L2"
})
)
).toEqual("L2");
afterEach(() => {
// Always reset the date after each test to avoid side effects
MockDate.reset();
});

it("returns the auth level when it is set", () => {
const state = appReducer(undefined, applicationChangeState("active"));
const updatedState = {
...state,
features: {
...state.features,
itWallet: {
...state.features?.itWallet,
preferences: {
...state.features?.itWallet?.preferences,
authLevel: "L2" as ItwAuthLevel
}
}
}
};

expect(itwAuthLevelSelector(updatedState)).toEqual("L2");
});

it("returns undefined when the auth level is not set", () => {
const state = appReducer(undefined, applicationChangeState("active"));
const updatedState = {
...state,
features: {
...state.features,
itWallet: {
...state.features?.itWallet,
preferences: {
...state.features?.itWallet?.preferences,
authLevel: undefined
}
}
}
};

expect(itwAuthLevelSelector(updatedState)).toBeUndefined();
});
});

0 comments on commit ac82e91

Please sign in to comment.