Skip to content

Commit 0beb37e

Browse files
committed
add more tests
1 parent 4c3434e commit 0beb37e

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/search/test_cases/__snapshots__/search_dates.test.e2e.ts.snap

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Date Search (e2e tests) BasicSearchManager.search() search('1999') should return cves including undefined 1`] = `
4+
Array [
5+
"CVE-1999-0529",
6+
]
7+
`;
8+
9+
exports[`Date Search (e2e tests) BasicSearchManager.search() search('2022-01-11') should return cves including CVE-2022-21963 1`] = `
10+
Array [
11+
"CVE-2021-45052",
12+
"CVE-2022-21833",
13+
"CVE-2022-21834",
14+
"CVE-2022-21836",
15+
"CVE-2022-21843",
16+
"CVE-2022-21862",
17+
"CVE-2022-21864",
18+
"CVE-2022-21867",
19+
"CVE-2022-21880",
20+
"CVE-2022-21881",
21+
"CVE-2022-21883",
22+
"CVE-2022-21894",
23+
"CVE-2022-21900",
24+
"CVE-2022-21903",
25+
"CVE-2022-21904",
26+
"CVE-2022-21908",
27+
"CVE-2022-21916",
28+
"CVE-2022-21924",
29+
"CVE-2022-21958",
30+
"CVE-2022-21960",
31+
"CVE-2022-21961",
32+
"CVE-2022-21962",
33+
"CVE-2022-21963",
34+
]
35+
`;
36+
337
exports[`Date Search (e2e tests) BasicSearchManager.search() search('2024-06-14') should return cves including CVE-2024-6006 1`] = `
438
Array [
539
"CVE-2024-31162",

src/search/test_cases/search_dates.test.e2e.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ describe('Date Search (e2e tests)', () => {
1212

1313
describe.only('BasicSearchManager.search()', () => {
1414
// expected defaults to false in this series!
15-
const testCases: Array<{ input: string; expected?: number; first?: string; includes: string; snapshot?: boolean}> = [
15+
const testCases: Array<{ input: string; expected?: number; first?: string; includes?: string; snapshot?: boolean; }> = [
1616
// valid dates
17-
// { input: `2022-01-11`, expected: 892, includes: "CVE-2022-31279", snapshot: false }, // developer tools returns 861 instead
18-
{ input: `2024-06-14`, expected: 4, includes: "CVE-2024-6006", snapshot: true }, // developer tools returns 138 instead
19-
{ input: `2025-01-11`, expected: 2, includes: "CVE-2024-42169", snapshot: true } // developer tools reads 9 instead of 24
17+
{ input: `2022-01-11`, expected: 23, includes: "CVE-2022-21963", snapshot: true },
18+
// { input: `2025-01-11T02:31:22.611Z`, expected: 1, includes: "CVE-2024-42169", snapshot: true },
19+
{ input: `2024-06-14`, expected: 4, includes: "CVE-2024-6006", snapshot: true },
20+
{ input: `2025-01-11`, expected: 2, includes: "CVE-2024-42169", snapshot: true },
21+
{ input: `1999`, expected: 0, snapshot: true },
22+
// { input: `2022`, expected: 0, snapshot: true },
23+
// { input: `2022-01`, expected: 12, includes: "CVE-2022-40621", snapshot: true }, // why search by month results in less than search by date in same month
24+
// invalid dates
25+
2026
];
2127

2228
testCases.forEach(({ input, expected, first, includes, snapshot }) => {
@@ -39,6 +45,7 @@ describe('Date Search (e2e tests)', () => {
3945
const cveIdMap = retlist.map(cve => {
4046
cves.push(cve["_id"])
4147
})
48+
console.log(`cves: ${JSON.stringify(cves, null, 2)}`)
4249
if (snapshot) {
4350
expect(cves.sort()).toMatchSnapshot();
4451
}

0 commit comments

Comments
 (0)