Files
sentinel/static/app/utils/useIsSentryEmployee.spec.tsx
2024-02-15 17:01:50 +00:00

65 lines
1.6 KiB
TypeScript

import {ConfigFixture} from 'sentry-fixture/config';
import {UserFixture} from 'sentry-fixture/user';
import {reactHooks} from 'sentry-test/reactTestingLibrary';
import ConfigStore from 'sentry/stores/configStore';
import {useIsSentryEmployee} from 'sentry/utils/useIsSentryEmployee';
describe('useIsSentryEmployee', () => {
it('should return true if the user is a Sentry employee', () => {
ConfigStore.config = ConfigFixture({
user: UserFixture({
emails: [
{
email: '[email protected]',
is_verified: true,
id: '1',
},
],
}),
});
const {result} = reactHooks.renderHook(() => useIsSentryEmployee());
expect(result.current).toBe(true);
});
it('should return false if the user is not a Sentry employee', () => {
// Mock ConfigStore to simulate a non-Sentry employee
ConfigStore.config = ConfigFixture({
user: UserFixture({
emails: [
{
email: '[email protected]',
is_verified: true,
id: '1',
},
],
}),
});
const {result} = reactHooks.renderHook(() => useIsSentryEmployee());
expect(result.current).toBe(false);
});
it('should return false if the email is not verified', () => {
ConfigStore.config = ConfigFixture({
user: UserFixture({
emails: [
{
email: '[email protected]',
is_verified: false,
id: '1',
},
],
}),
});
const {result} = reactHooks.renderHook(() => useIsSentryEmployee());
expect(result.current).toBe(false);
});
});