mirror of
https://github.com/firstsun-dev/git-files-sync.git
synced 2026-07-22 17:20:30 +00:00
- Add SHA comparison in pushFile to detect remote changes before pushing - Update syncMetadata (lastSyncedSha) after successful push and pull - Add comprehensive test cases for conflict scenarios and metadata updates - Use syncMetadata to track state and prevent overwriting remote work Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
65 lines
1.5 KiB
TypeScript
65 lines
1.5 KiB
TypeScript
import { vi } from 'vitest';
|
|
|
|
// Mock global browser environment if not in JSDOM
|
|
if (typeof document === 'undefined') {
|
|
(globalThis as unknown as { document: unknown }).document = {
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
};
|
|
}
|
|
if (typeof window === 'undefined') {
|
|
(globalThis as unknown as { window: unknown }).window = {
|
|
setInterval: vi.fn(),
|
|
clearInterval: vi.fn(),
|
|
};
|
|
}
|
|
|
|
// Mock Obsidian API components
|
|
export const Plugin = class {};
|
|
export const PluginSettingTab = class {
|
|
constructor(_app: unknown, _plugin: unknown) {}
|
|
};
|
|
export const Setting = class {
|
|
constructor(_containerEl: unknown) {}
|
|
setName(_name: string) { return this; }
|
|
setDesc(_desc: string) { return this; }
|
|
addText(_cb: unknown) { return this; }
|
|
addToggle(_cb: unknown) { return this; }
|
|
addButton(_cb: unknown) { return this; }
|
|
};
|
|
export const Notice = vi.fn().mockImplementation((message: string) => ({}));
|
|
export const Modal = class {
|
|
constructor(_app: unknown) {}
|
|
open() {}
|
|
close() {}
|
|
};
|
|
export const MarkdownView = class {};
|
|
export const Editor = class {};
|
|
export const App = class {
|
|
workspace = {
|
|
getActiveViewOfType: vi.fn(),
|
|
on: vi.fn(),
|
|
};
|
|
vault = {
|
|
read: vi.fn(),
|
|
modify: vi.fn(),
|
|
on: vi.fn(),
|
|
adapter: {
|
|
getBasePath: vi.fn().mockReturnValue('/mock/path'),
|
|
},
|
|
};
|
|
};
|
|
|
|
export const TFile = class {};
|
|
|
|
vi.mock('obsidian', () => ({
|
|
Plugin,
|
|
PluginSettingTab,
|
|
Setting,
|
|
Notice,
|
|
Modal,
|
|
MarkdownView,
|
|
Editor,
|
|
App,
|
|
TFile,
|
|
}));
|