import LocalStorageStrategy from "./localStorage";

describe("LocalStorageStrategy", () => {
    describe("available", () => {
        it("should return true if localStorage is available", () => {
            const localStorageMock = {
                setItem: jest.fn(),
                removeItem: jest.fn(),
            };
            expect(
                LocalStorageStrategy.available({ window: {}, localStorage: localStorageMock })
            ).toBe(true);
        });
        it("should return false if localStorage is not available", () => {
            const windowMock = {};
            expect(LocalStorageStrategy.available({ window: windowMock })).toBe(false);
        });
        it("should return false if window is not available", () => {
            expect(LocalStorageStrategy.available({ window: undefined })).toBe(false);
        });
    });
});
