mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
65 lines
1.6 KiB
TypeScript
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);
|
|
});
|
|
});
|