import React from "react";
import { render, screen } from "@testing-library/react";
import AuthProvider, { AuthContext } from "../src/AuthProvider";
import "@testing-library/jest-dom";
describe("AuthProvider", () => {
    it("should provide default user and roles as null and empty array", () => {
        render(
            <AuthProvider>
                <AuthContext.Consumer>
                    {({ user, roles }) => (
                        <>
                            <div data-testid="user">{user ? user.name : "null"}</div>
                            <div data-testid="roles">{roles.length}</div>
                        </>
                    )}
                </AuthContext.Consumer>
            </AuthProvider>
        );

        expect(screen.getByTestId("user")).toHaveTextContent("null");
        expect(screen.getByTestId("roles")).toHaveTextContent("0");
    });
});