trimSlug.spec.tsx 932 B

12345678910111213141516171819202122
  1. import {trimSlug} from 'sentry/utils/trimSlug';
  2. describe('trimSlug', function () {
  3. it('returns slug if it is already short enough', function () {
  4. expect(trimSlug('javascript', 20)).toBe('javascript');
  5. });
  6. it('trims long but unhyphenated slug', function () {
  7. expect(trimSlug('javascriptfrontendproject', 20)).toBe('javascriptfrontendp…');
  8. });
  9. it('trims slug from the middle, preserves whole words', function () {
  10. expect(trimSlug('symbol-collector-console', 20)).toBe('symbol…console');
  11. expect(trimSlug('symbol-collector-mobile', 20)).toBe('symbol…mobile');
  12. expect(trimSlug('visual-snapshot-cloud-run', 20)).toBe('visual…cloud-run');
  13. });
  14. it('trims slug from the middle, cuts whole words', function () {
  15. expect(trimSlug('sourcemapsio-javascript', 20)).toBe('sourcemaps…javascript');
  16. expect(trimSlug('armcknight-ios-ephemeraldemo', 20)).toBe('armcknig…phemeraldemo');
  17. });
  18. });