33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
55import { it , expect } from "@jest/globals" ;
6- import {
7- createRandomBreach ,
8- createRandomScanResult ,
9- } from "../../../../../../../apiMocks/mockData" ;
6+ import { createRandomBreach } from "../../../../../../../apiMocks/mockData" ;
107import { filterExposures } from "./filterExposures" ;
118import { CONST_DAY_MILLISECONDS } from "../../../../../../../constants" ;
129jest . mock ( "../../../../../../hooks/useTelemetry" ) ;
@@ -30,33 +27,12 @@ const breachOld = createRandomBreach({
3027 addedDate : getDateDaysAgo ( 1000 ) ,
3128} ) ;
3229
33- const scanResultThisWeek = createRandomScanResult ( {
34- fakerSeed : 1234 ,
35- createdDate : getDateDaysAgo ( 2 ) ,
36- } ) ;
37- const scanResultThisMonth = createRandomScanResult ( {
38- fakerSeed : 1234 ,
39- createdDate : getDateDaysAgo ( 10 ) ,
40- } ) ;
41- const scanResultThisYear = createRandomScanResult ( {
42- fakerSeed : 1234 ,
43- createdDate : getDateDaysAgo ( 100 ) ,
44- } ) ;
45- const scanResultOld = createRandomScanResult ( {
46- fakerSeed : 1234 ,
47- createdDate : getDateDaysAgo ( 1000 ) ,
48- } ) ;
49-
5030it ( "doesn't filter out anything by default" , ( ) => {
5131 const exposures = [
5232 breachThisWeek ,
53- scanResultThisWeek ,
5433 breachThisMonth ,
55- scanResultThisMonth ,
5634 breachThisYear ,
57- scanResultThisYear ,
5835 breachOld ,
59- scanResultOld ,
6036 ] ;
6137
6238 expect (
@@ -70,38 +46,25 @@ it("doesn't filter out anything by default", () => {
7046it ( "can filter out breaches" , ( ) => {
7147 const exposures = [
7248 breachThisWeek ,
73- scanResultThisWeek ,
7449 breachThisMonth ,
75- scanResultThisMonth ,
7650 breachThisYear ,
77- scanResultThisYear ,
7851 breachOld ,
79- scanResultOld ,
8052 ] ;
8153
8254 expect (
8355 filterExposures ( exposures , {
8456 dateFound : "show-all-date-found" ,
8557 exposureType : "data-broker" ,
8658 } ) ,
87- ) . toStrictEqual ( [
88- scanResultThisWeek ,
89- scanResultThisMonth ,
90- scanResultThisYear ,
91- scanResultOld ,
92- ] ) ;
59+ ) . toStrictEqual ( [ ] ) ;
9360} ) ;
9461
9562it ( "can filter out data brokers" , ( ) => {
9663 const exposures = [
9764 breachThisWeek ,
98- scanResultThisWeek ,
9965 breachThisMonth ,
100- scanResultThisMonth ,
10166 breachThisYear ,
102- scanResultThisYear ,
10367 breachOld ,
104- scanResultOld ,
10568 ] ;
10669
10770 expect (
@@ -115,85 +78,57 @@ it("can filter out data brokers", () => {
11578it ( "can filter out exposures older than a year" , ( ) => {
11679 const exposures = [
11780 breachThisWeek ,
118- scanResultThisWeek ,
11981 breachThisMonth ,
120- scanResultThisMonth ,
12182 breachThisYear ,
122- scanResultThisYear ,
12383 breachOld ,
124- scanResultOld ,
12584 ] ;
12685
12786 expect (
12887 filterExposures ( exposures , {
12988 dateFound : "last-year" ,
13089 exposureType : "show-all-exposure-type" ,
13190 } ) ,
132- ) . toStrictEqual ( [
133- breachThisWeek ,
134- scanResultThisWeek ,
135- breachThisMonth ,
136- scanResultThisMonth ,
137- breachThisYear ,
138- scanResultThisYear ,
139- ] ) ;
91+ ) . toStrictEqual ( [ breachThisWeek , breachThisMonth , breachThisYear ] ) ;
14092} ) ;
14193
14294it ( "can filter out exposures older than a month" , ( ) => {
14395 const exposures = [
14496 breachThisWeek ,
145- scanResultThisWeek ,
14697 breachThisMonth ,
147- scanResultThisMonth ,
14898 breachThisYear ,
149- scanResultThisYear ,
15099 breachOld ,
151- scanResultOld ,
152100 ] ;
153101
154102 expect (
155103 filterExposures ( exposures , {
156104 dateFound : "thirty-days" ,
157105 exposureType : "show-all-exposure-type" ,
158106 } ) ,
159- ) . toStrictEqual ( [
160- breachThisWeek ,
161- scanResultThisWeek ,
162- breachThisMonth ,
163- scanResultThisMonth ,
164- ] ) ;
107+ ) . toStrictEqual ( [ breachThisWeek , breachThisMonth ] ) ;
165108} ) ;
166109
167110it ( "can filter out exposures older than a week" , ( ) => {
168111 const exposures = [
169112 breachThisWeek ,
170- scanResultThisWeek ,
171113 breachThisMonth ,
172- scanResultThisMonth ,
173114 breachThisYear ,
174- scanResultThisYear ,
175115 breachOld ,
176- scanResultOld ,
177116 ] ;
178117
179118 expect (
180119 filterExposures ( exposures , {
181120 dateFound : "seven-days" ,
182121 exposureType : "show-all-exposure-type" ,
183122 } ) ,
184- ) . toStrictEqual ( [ breachThisWeek , scanResultThisWeek ] ) ;
123+ ) . toStrictEqual ( [ breachThisWeek ] ) ;
185124} ) ;
186125
187126it ( "filters out anything that doesn't match *all* filters" , ( ) => {
188127 const exposures = [
189128 breachThisWeek ,
190- scanResultThisWeek ,
191129 breachThisMonth ,
192- scanResultThisMonth ,
193130 breachThisYear ,
194- scanResultThisYear ,
195131 breachOld ,
196- scanResultOld ,
197132 ] ;
198133
199134 expect (
0 commit comments