mirror of
https://github.com/Kong/insomnia.git
synced 2026-09-17 18:43:35 -04:00
* feat(git): implement folderSlug for Git repositories and add slugify utility * fix(project): wait for modal backdrop to hide before clicking next button * feat(git): enhance folderSlug validation and path resolution for Git repositories * fix(git): improve fallback path resolution for git repositories to ensure safety * fix(project): handle unsaved changes confirmation when closing project modal * fix(project): handle race condition in unsaved changes confirmation dialog when closing project modal
30 lines
875 B
TypeScript
30 lines
875 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { slugify } from './misc';
|
|
|
|
describe('slugify', () => {
|
|
it('lowercases and joins words with hyphens', () => {
|
|
expect(slugify('Cams Project!')).toBe('cams-project');
|
|
});
|
|
|
|
it('strips accents', () => {
|
|
expect(slugify('Café México')).toBe('cafe-mexico');
|
|
});
|
|
|
|
it('collapses runs of non-alphanumeric characters', () => {
|
|
expect(slugify(' --Weird__Name-- ')).toBe('weird-name');
|
|
});
|
|
|
|
it('returns an empty string when nothing usable remains', () => {
|
|
expect(slugify('🚀🚀🚀')).toBe('');
|
|
});
|
|
|
|
it('truncates to maxLength without leaving a trailing hyphen', () => {
|
|
const longName = 'a-very-long-project-name-that-goes-on-and-on-and-on';
|
|
const slug = slugify(longName, 20);
|
|
|
|
expect(slug.length).toBeLessThanOrEqual(20);
|
|
expect(slug.endsWith('-')).toBe(false);
|
|
});
|
|
});
|