mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 01:02:01 +03:00
Merge f97801b2cc into 37cfd2144b
This commit is contained in:
commit
0401d8b974
1 changed files with 26 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { logger } from "./logger";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { isTauri, loadSettings, saveSettings, defaultSettingsData, loadAppData, saveAppData, flushAppData, setDataDir, runBackups, backupDeletedSheet, openBackupsFolder, chooseFolder, dataDirHasDocuments, migrateDataDir, fetchRates, fetchHistoricalRates } from './storage';
|
||||
import { isTauri, loadSettings, saveSettings, defaultSettingsData, loadAppData, saveAppData, flushAppData, setDataDir, runBackups, backupDeletedSheet, openBackupsFolder, chooseFolder, dataDirHasDocuments, migrateDataDir, fetchRates, fetchHistoricalRates, getLaunchFile } from './storage';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
vi.mock('@tauri-apps/api/core', () => ({
|
||||
|
|
@ -416,4 +416,29 @@ describe('storage', () => {
|
|||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLaunchFile', () => {
|
||||
it('returns null if not in Tauri', async () => {
|
||||
vi.stubGlobal('window', {});
|
||||
expect(await getLaunchFile()).toBeNull();
|
||||
});
|
||||
|
||||
it('returns launch file path if in Tauri', async () => {
|
||||
vi.stubGlobal('window', { __TAURI_INTERNALS__: {} });
|
||||
vi.mocked(invoke).mockResolvedValueOnce('/path/to/file.numi');
|
||||
|
||||
const result = await getLaunchFile();
|
||||
expect(invoke).toHaveBeenCalledWith('get_launch_file', undefined);
|
||||
expect(result).toBe('/path/to/file.numi');
|
||||
});
|
||||
|
||||
it('returns null if invoke fails', async () => {
|
||||
vi.stubGlobal('window', { __TAURI_INTERNALS__: {} });
|
||||
vi.mocked(invoke).mockRejectedValueOnce(new Error('invoke failed'));
|
||||
|
||||
const result = await getLaunchFile();
|
||||
expect(invoke).toHaveBeenCalledWith('get_launch_file', undefined);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue