getRouteStringFromRoutes.spec.jsx 812 B

1234567891011121314151617181920212223
  1. import getRouteStringFromRoutes from 'sentry/utils/getRouteStringFromRoutes';
  2. describe('getRouteStringFromRoutes', function () {
  3. const routes = [
  4. {path: '/'},
  5. {path: '/:orgId/'},
  6. {name: 'this should be skipped'},
  7. {path: '/organizations/:orgId/'},
  8. {name: 'also skipped'},
  9. {path: 'api-keys/', name: 'API Key'},
  10. ];
  11. it('can get a route string from routes array and skips routes that do not have a path', function () {
  12. expect(getRouteStringFromRoutes(routes)).toBe('/organizations/:orgId/api-keys/');
  13. });
  14. it('handles invalid `routes` values', function () {
  15. expect(getRouteStringFromRoutes(null)).toBe('');
  16. expect(getRouteStringFromRoutes('')).toBe('');
  17. expect(getRouteStringFromRoutes({})).toBe('');
  18. expect(getRouteStringFromRoutes(false)).toBe('');
  19. });
  20. });