Address code review feedback - improve test cleanup and remove redundant test

Co-authored-by: rfc1437 <774975+rfc1437@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-15 10:53:22 +00:00
parent 5ef81d9e5e
commit c785048406
2 changed files with 24 additions and 6 deletions

View File

@@ -613,16 +613,38 @@ describe('TagEngine', () => {
});
it('should return empty array when client is not available', async () => {
// Store original mock implementation
const originalMock = vi.mocked(getDatabase).getMockImplementation();
// Mock getClient to return null
const mockGetClient = vi.fn().mockReturnValue(null);
vi.mocked(getDatabase).mockReturnValue({
getLocal: vi.fn(() => mockLocalDb),
getLocalClient: mockGetClient,
getLocalClient: vi.fn().mockReturnValue(null),
} as any);
const result = await tagEngine.getPostsWithTag('tag-1');
expect(result).toEqual([]);
// Restore original mock
if (originalMock) {
vi.mocked(getDatabase).mockImplementation(originalMock);
} else {
// Restore to standard mock
vi.mocked(getDatabase).mockReturnValue({
getLocal: vi.fn(() => mockLocalDb),
getLocalClient: vi.fn(() => mockLocalClient),
getRemote: vi.fn(() => null),
getDataPaths: vi.fn(() => ({
database: '/mock/userData/bds.db',
posts: '/mock/userData/posts',
media: '/mock/userData/media',
})),
initializeLocal: vi.fn(),
initializeRemote: vi.fn(),
close: vi.fn(),
} as any);
}
});
});
});

View File

@@ -137,10 +137,6 @@ describe('stemmer', () => {
expect(stemText(' ', 'english')).toBe('');
});
it('should return empty string for null/undefined-like empty text', () => {
expect(stemText('', 'english')).toBe('');
});
it('should handle multiple spaces between words', () => {
const result = stemText('Running dogs are playing', 'english');
const words = result.split(' ');