n8n-nodes-duckduckgo-search
Version:
A powerful and comprehensive n8n community node that seamlessly integrates DuckDuckGo search capabilities into your workflows. Search the web, find images, discover news, and explore videos - all with privacy-focused, reliable results.
54 lines (53 loc) • 2.21 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vqdPagination_1 = require("../vqdPagination");
jest.mock('duck-duck-scrape', () => ({
search: jest.fn(),
}));
const duck_duck_scrape_1 = require("duck-duck-scrape");
const mockSearch = duck_duck_scrape_1.search;
describe('VQD Pagination', () => {
beforeEach(() => {
jest.clearAllMocks();
(0, vqdPagination_1.clearVqdTokenCache)();
});
describe('Cache Management', () => {
it('should cache VQD tokens properly', async () => {
mockSearch.mockResolvedValueOnce({
results: [{ title: 'Result 1', url: 'https://example1.com' }],
vqd: 'cached-token-123',
});
await (0, vqdPagination_1.paginateWithVqd)('cache test', {}, {
maxResults: 1,
pageSize: 10,
maxPages: 1,
delayBetweenRequests: 10,
});
expect((0, vqdPagination_1.getVqdTokenCacheSize)()).toBe(1);
(0, vqdPagination_1.clearVqdTokenCache)();
expect((0, vqdPagination_1.getVqdTokenCacheSize)()).toBe(0);
});
it('should handle basic pagination request', async () => {
mockSearch.mockResolvedValueOnce({
results: [
{ title: 'Result 1', url: 'https://example1.com' },
{ title: 'Result 2', url: 'https://example2.com' },
],
vqd: 'test-vqd-token-123',
});
const options = {
maxResults: 5,
pageSize: 10,
maxPages: 3,
delayBetweenRequests: 10,
debugMode: false,
};
const result = await (0, vqdPagination_1.paginateWithVqd)('test query', {}, options);
expect(result.results).toHaveLength(2);
expect(result.totalFetched).toBe(2);
expect(result.vqdToken).toBe('test-vqd-token-123');
expect(result.hasMore).toBe(false);
expect(['primary', 'fallback', 'hybrid']).toContain(result.strategy);
});
});
});