import React, { useContext } from 'react';
import { IdentityContext } from '@theorchard/suite-frontend';
import { createIdentity } from '@theorchard/suite-testing';

const actualUseContext = useContext;

export const mockIdentity = (roles: string[]) => {
    jest.spyOn(React, 'useContext').mockImplementation(context => {
        if (context === IdentityContext)
            return {
                identity: createIdentity({ roles }),
            };
        return actualUseContext(context);
    });
};
