1 import { adjustName, splitLinkName } from './link';
3 describe('adjustName', () => {
4 it('should add index to a file with extension', () => {
5 expect(adjustName(3, 'filename', 'ext')).toBe('filename (3).ext');
8 it('should add index to a file without extension', () => {
9 expect(adjustName(3, 'filename')).toBe('filename (3)');
10 expect(adjustName(3, 'filename', '')).toBe('filename (3)');
11 expect(adjustName(3, 'filename.')).toBe('filename. (3)');
12 expect(adjustName(3, '.filename.')).toBe('.filename. (3)');
15 it('should add index to a file without name', () => {
16 expect(adjustName(3, '', 'ext')).toBe('.ext (3)');
19 it('should leave zero-index filename with extension unchanged', () => {
20 expect(adjustName(0, 'filename', 'ext')).toBe('filename.ext');
23 it('should leave zero-index filename without extension unchanged', () => {
24 expect(adjustName(0, 'filename')).toBe('filename');
25 expect(adjustName(0, 'filename', '')).toBe('filename');
26 expect(adjustName(0, 'filename.')).toBe('filename.');
27 expect(adjustName(0, '.filename.')).toBe('.filename.');
30 it('should leave zero-index filename without name unchanged', () => {
31 expect(adjustName(0, '', 'ext')).toBe('.ext');
35 describe('splitLinkName', () => {
36 it('should split file name and extension', () => {
37 expect(splitLinkName('filename.ext')).toEqual(['filename', 'ext']);
40 it('should split file name without extension', () => {
41 expect(splitLinkName('filename')).toEqual(['filename', '']);
42 expect(splitLinkName('filename.')).toEqual(['filename.', '']);
45 it('should split file name without name', () => {
46 expect(splitLinkName('.ext')).toEqual(['', 'ext']);