@oevortex/ddg_search 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -26
- package/README.md +14 -3
- package/babel.config.js +11 -11
- package/bin/cli.js +14 -8
- package/package.json +1 -1
- package/src/index.js +6 -1
- package/src/index.ts +6 -1
- package/src/tools/braveTool.js +63 -0
- package/src/tools/searchTool.js +40 -40
- package/src/utils/search.js +322 -322
- package/src/utils/search_brave_ai.js +167 -0
- package/src/utils/search_iask.js +228 -228
- package/src/utils/search_monica.js +238 -238
- package/test.setup.js +119 -119
package/test.setup.js
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
// Global test setup
|
|
2
|
-
import { jest } from '@jest/globals';
|
|
3
|
-
|
|
4
|
-
// Mock console methods to reduce noise in tests
|
|
5
|
-
global.console = {
|
|
6
|
-
...console,
|
|
7
|
-
log: jest.fn(),
|
|
8
|
-
error: jest.fn(),
|
|
9
|
-
warn: jest.fn(),
|
|
10
|
-
info: jest.fn(),
|
|
11
|
-
debug: jest.fn()
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Increase test timeout for integration tests
|
|
15
|
-
jest.setTimeout(30000);
|
|
16
|
-
|
|
17
|
-
// Global test utilities
|
|
18
|
-
global.mockDelay = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms));
|
|
19
|
-
|
|
20
|
-
// Mock WebSocket class
|
|
21
|
-
global.WebSocket = jest.fn().mockImplementation(() => ({
|
|
22
|
-
close: jest.fn(),
|
|
23
|
-
send: jest.fn(),
|
|
24
|
-
addEventListener: jest.fn(),
|
|
25
|
-
removeEventListener: jest.fn()
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
// Mock axios
|
|
29
|
-
const mockAxios = jest.fn(() => Promise.resolve({
|
|
30
|
-
status: 200,
|
|
31
|
-
data: '<html><body>Mock Response</body></html>',
|
|
32
|
-
config: { url: 'http://example.com' },
|
|
33
|
-
request: { res: { responseUrl: 'http://example.com' } }
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
mockAxios.get = jest.fn();
|
|
37
|
-
mockAxios.post = jest.fn();
|
|
38
|
-
|
|
39
|
-
jest.mock('axios', () => mockAxios);
|
|
40
|
-
|
|
41
|
-
// Mock external modules
|
|
42
|
-
jest.mock('cheerio', () => ({
|
|
43
|
-
load: jest.fn(() => ({
|
|
44
|
-
find: jest.fn(() => ({
|
|
45
|
-
each: jest.fn(),
|
|
46
|
-
text: jest.fn(() => 'Mock Title'),
|
|
47
|
-
attr: jest.fn(() => 'http://example.com')
|
|
48
|
-
})),
|
|
49
|
-
html: jest.fn(() => '<div>Mock Content</div>'),
|
|
50
|
-
text: jest.fn(() => 'Mock Text Content')
|
|
51
|
-
}))
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
jest.mock('ws', () => jest.fn());
|
|
55
|
-
|
|
56
|
-
jest.mock('turndown', () => jest.fn(() => ({
|
|
57
|
-
turndown: jest.fn((html) => html.replace(/<[^>]*>/g, ''))
|
|
58
|
-
})));
|
|
59
|
-
|
|
60
|
-
jest.mock('tough-cookie', () => ({
|
|
61
|
-
CookieJar: jest.fn(() => ({
|
|
62
|
-
getCookies: jest.fn(() => []),
|
|
63
|
-
setCookie: jest.fn()
|
|
64
|
-
}))
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
jest.mock('axios-cookiejar-support', () => ({
|
|
68
|
-
wrapper: jest.fn((axios) => axios)
|
|
69
|
-
}));
|
|
70
|
-
|
|
71
|
-
jest.mock('crypto', () => ({
|
|
72
|
-
randomUUID: jest.fn(() => 'mock-uuid-12345')
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
// Mock axios
|
|
76
|
-
const mockAxios = jest.fn(() => Promise.resolve({
|
|
77
|
-
status: 200,
|
|
78
|
-
data: '<html><body>Mock Response</body></html>',
|
|
79
|
-
config: { url: 'http://example.com' },
|
|
80
|
-
request: { res: { responseUrl: 'http://example.com' } }
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
mockAxios.get = jest.fn();
|
|
84
|
-
mockAxios.post = jest.fn();
|
|
85
|
-
|
|
86
|
-
jest.mock('axios', () => mockAxios);
|
|
87
|
-
|
|
88
|
-
// Mock external modules
|
|
89
|
-
jest.mock('cheerio', () => ({
|
|
90
|
-
load: jest.fn(() => ({
|
|
91
|
-
find: jest.fn(() => ({
|
|
92
|
-
each: jest.fn(),
|
|
93
|
-
text: jest.fn(() => 'Mock Title'),
|
|
94
|
-
attr: jest.fn(() => 'http://example.com')
|
|
95
|
-
})),
|
|
96
|
-
html: jest.fn(() => '<div>Mock Content</div>'),
|
|
97
|
-
text: jest.fn(() => 'Mock Text Content')
|
|
98
|
-
}))
|
|
99
|
-
}));
|
|
100
|
-
|
|
101
|
-
jest.mock('ws', () => jest.fn());
|
|
102
|
-
|
|
103
|
-
jest.mock('turndown', () => jest.fn(() => ({
|
|
104
|
-
turndown: jest.fn((html) => html.replace(/<[^>]*>/g, ''))
|
|
105
|
-
})));
|
|
106
|
-
|
|
107
|
-
jest.mock('tough-cookie', () => ({
|
|
108
|
-
CookieJar: jest.fn(() => ({
|
|
109
|
-
getCookies: jest.fn(() => []),
|
|
110
|
-
setCookie: jest.fn()
|
|
111
|
-
}))
|
|
112
|
-
}));
|
|
113
|
-
|
|
114
|
-
jest.mock('axios-cookiejar-support', () => ({
|
|
115
|
-
wrapper: jest.fn((axios) => axios)
|
|
116
|
-
}));
|
|
117
|
-
|
|
118
|
-
jest.mock('crypto', () => ({
|
|
119
|
-
randomUUID: jest.fn(() => 'mock-uuid-12345')
|
|
1
|
+
// Global test setup
|
|
2
|
+
import { jest } from '@jest/globals';
|
|
3
|
+
|
|
4
|
+
// Mock console methods to reduce noise in tests
|
|
5
|
+
global.console = {
|
|
6
|
+
...console,
|
|
7
|
+
log: jest.fn(),
|
|
8
|
+
error: jest.fn(),
|
|
9
|
+
warn: jest.fn(),
|
|
10
|
+
info: jest.fn(),
|
|
11
|
+
debug: jest.fn()
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Increase test timeout for integration tests
|
|
15
|
+
jest.setTimeout(30000);
|
|
16
|
+
|
|
17
|
+
// Global test utilities
|
|
18
|
+
global.mockDelay = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms));
|
|
19
|
+
|
|
20
|
+
// Mock WebSocket class
|
|
21
|
+
global.WebSocket = jest.fn().mockImplementation(() => ({
|
|
22
|
+
close: jest.fn(),
|
|
23
|
+
send: jest.fn(),
|
|
24
|
+
addEventListener: jest.fn(),
|
|
25
|
+
removeEventListener: jest.fn()
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
// Mock axios
|
|
29
|
+
const mockAxios = jest.fn(() => Promise.resolve({
|
|
30
|
+
status: 200,
|
|
31
|
+
data: '<html><body>Mock Response</body></html>',
|
|
32
|
+
config: { url: 'http://example.com' },
|
|
33
|
+
request: { res: { responseUrl: 'http://example.com' } }
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
mockAxios.get = jest.fn();
|
|
37
|
+
mockAxios.post = jest.fn();
|
|
38
|
+
|
|
39
|
+
jest.mock('axios', () => mockAxios);
|
|
40
|
+
|
|
41
|
+
// Mock external modules
|
|
42
|
+
jest.mock('cheerio', () => ({
|
|
43
|
+
load: jest.fn(() => ({
|
|
44
|
+
find: jest.fn(() => ({
|
|
45
|
+
each: jest.fn(),
|
|
46
|
+
text: jest.fn(() => 'Mock Title'),
|
|
47
|
+
attr: jest.fn(() => 'http://example.com')
|
|
48
|
+
})),
|
|
49
|
+
html: jest.fn(() => '<div>Mock Content</div>'),
|
|
50
|
+
text: jest.fn(() => 'Mock Text Content')
|
|
51
|
+
}))
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
jest.mock('ws', () => jest.fn());
|
|
55
|
+
|
|
56
|
+
jest.mock('turndown', () => jest.fn(() => ({
|
|
57
|
+
turndown: jest.fn((html) => html.replace(/<[^>]*>/g, ''))
|
|
58
|
+
})));
|
|
59
|
+
|
|
60
|
+
jest.mock('tough-cookie', () => ({
|
|
61
|
+
CookieJar: jest.fn(() => ({
|
|
62
|
+
getCookies: jest.fn(() => []),
|
|
63
|
+
setCookie: jest.fn()
|
|
64
|
+
}))
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
jest.mock('axios-cookiejar-support', () => ({
|
|
68
|
+
wrapper: jest.fn((axios) => axios)
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
jest.mock('crypto', () => ({
|
|
72
|
+
randomUUID: jest.fn(() => 'mock-uuid-12345')
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
// Mock axios
|
|
76
|
+
const mockAxios = jest.fn(() => Promise.resolve({
|
|
77
|
+
status: 200,
|
|
78
|
+
data: '<html><body>Mock Response</body></html>',
|
|
79
|
+
config: { url: 'http://example.com' },
|
|
80
|
+
request: { res: { responseUrl: 'http://example.com' } }
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
mockAxios.get = jest.fn();
|
|
84
|
+
mockAxios.post = jest.fn();
|
|
85
|
+
|
|
86
|
+
jest.mock('axios', () => mockAxios);
|
|
87
|
+
|
|
88
|
+
// Mock external modules
|
|
89
|
+
jest.mock('cheerio', () => ({
|
|
90
|
+
load: jest.fn(() => ({
|
|
91
|
+
find: jest.fn(() => ({
|
|
92
|
+
each: jest.fn(),
|
|
93
|
+
text: jest.fn(() => 'Mock Title'),
|
|
94
|
+
attr: jest.fn(() => 'http://example.com')
|
|
95
|
+
})),
|
|
96
|
+
html: jest.fn(() => '<div>Mock Content</div>'),
|
|
97
|
+
text: jest.fn(() => 'Mock Text Content')
|
|
98
|
+
}))
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
jest.mock('ws', () => jest.fn());
|
|
102
|
+
|
|
103
|
+
jest.mock('turndown', () => jest.fn(() => ({
|
|
104
|
+
turndown: jest.fn((html) => html.replace(/<[^>]*>/g, ''))
|
|
105
|
+
})));
|
|
106
|
+
|
|
107
|
+
jest.mock('tough-cookie', () => ({
|
|
108
|
+
CookieJar: jest.fn(() => ({
|
|
109
|
+
getCookies: jest.fn(() => []),
|
|
110
|
+
setCookie: jest.fn()
|
|
111
|
+
}))
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
jest.mock('axios-cookiejar-support', () => ({
|
|
115
|
+
wrapper: jest.fn((axios) => axios)
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
jest.mock('crypto', () => ({
|
|
119
|
+
randomUUID: jest.fn(() => 'mock-uuid-12345')
|
|
120
120
|
}));
|