consolidatedScopes.spec.tsx 713 B

123456789101112131415161718192021222324252627
  1. import {toPermissions, toResourcePermissions} from 'sentry/utils/consolidatedScopes';
  2. describe('ConsolidatedScopes', () => {
  3. let scopes;
  4. beforeEach(() => {
  5. scopes = ['event:read', 'event:admin', 'project:releases', 'org:read'];
  6. });
  7. it('exposes scopes, grouped for each resource', () => {
  8. expect(toResourcePermissions(scopes)).toEqual(
  9. expect.objectContaining({
  10. Event: 'admin',
  11. Release: 'admin',
  12. Organization: 'read',
  13. })
  14. );
  15. });
  16. it('exposes scopes, grouped by access level', () => {
  17. expect(toPermissions(scopes)).toEqual({
  18. admin: expect.arrayContaining(['Event', 'Release']),
  19. read: ['Organization'],
  20. write: [],
  21. });
  22. });
  23. });