-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
942dff7
commit 2fd40b4
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { app } from 'electron'; | ||
import path from 'path'; | ||
import { getModelConfigPath } from '../../src/config/extra_model_config'; | ||
|
||
// Mock electron | ||
jest.mock('electron', () => ({ | ||
app: { | ||
getPath: jest.fn(), | ||
}, | ||
})); | ||
|
||
describe('getModelConfigPath', () => { | ||
it('should return the correct path', async () => { | ||
// Mock the userData path | ||
const mockUserDataPath = '/fake/user/data'; | ||
(app.getPath as jest.Mock).mockImplementation((key: string) => { | ||
if (key === 'userData') { | ||
return mockUserDataPath; | ||
} | ||
throw new Error(`Unexpected getPath key: ${key}`); | ||
}); | ||
|
||
const result = await getModelConfigPath(); | ||
|
||
// Verify the path is correctly joined | ||
expect(result).toBe(path.join(mockUserDataPath, 'extra_model_paths.yaml')); | ||
|
||
// Verify app.getPath was called with correct argument | ||
expect(app.getPath).toHaveBeenCalledWith('userData'); | ||
}); | ||
}); |