consolidatedScopes.spec.jsx 747 B

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