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:
@@ -613,16 +613,38 @@ describe('TagEngine', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return empty array when client is not available', async () => {
|
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
|
// Mock getClient to return null
|
||||||
const mockGetClient = vi.fn().mockReturnValue(null);
|
|
||||||
vi.mocked(getDatabase).mockReturnValue({
|
vi.mocked(getDatabase).mockReturnValue({
|
||||||
getLocal: vi.fn(() => mockLocalDb),
|
getLocal: vi.fn(() => mockLocalDb),
|
||||||
getLocalClient: mockGetClient,
|
getLocalClient: vi.fn().mockReturnValue(null),
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
const result = await tagEngine.getPostsWithTag('tag-1');
|
const result = await tagEngine.getPostsWithTag('tag-1');
|
||||||
|
|
||||||
expect(result).toEqual([]);
|
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -137,10 +137,6 @@ describe('stemmer', () => {
|
|||||||
expect(stemText(' ', 'english')).toBe('');
|
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', () => {
|
it('should handle multiple spaces between words', () => {
|
||||||
const result = stemText('Running dogs are playing', 'english');
|
const result = stemText('Running dogs are playing', 'english');
|
||||||
const words = result.split(' ');
|
const words = result.split(' ');
|
||||||
|
|||||||
Reference in New Issue
Block a user