mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
refactor: rename project
This commit is contained in:
committed by
Carlos Valente
parent
c9ef8d55c1
commit
46195fc043
@@ -1,4 +1,4 @@
|
||||
import { deleteProjectFile, duplicateProjectFile } from '../ProjectService.js';
|
||||
import { deleteProjectFile, duplicateProjectFile, renameProjectFile } from '../ProjectService.js';
|
||||
import { appStateProvider } from '../../app-state-service/AppStateService.js';
|
||||
import { doesProjectExist } from '../projectServiceUtils.js';
|
||||
import { Mock } from 'vitest';
|
||||
@@ -54,3 +54,20 @@ describe('duplicateProjectFile', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('renameProjectFile', () => {
|
||||
it('throws an error if origin project does not exist', async () => {
|
||||
(doesProjectExist as Mock).mockReturnValue(false);
|
||||
await expect(renameProjectFile('does not exist', 'doesnt matter')).rejects.toThrow('Project file not found');
|
||||
});
|
||||
|
||||
it('throws an error if new file name is already a project', async () => {
|
||||
// current project exists
|
||||
(doesProjectExist as Mock).mockReturnValueOnce(true);
|
||||
// new project exists
|
||||
(doesProjectExist as Mock).mockReturnValueOnce(true);
|
||||
expect(renameProjectFile('nonexistentProject', 'existingproject')).rejects.toThrow(
|
||||
'Project file with name existingproject already exists',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user