@atproto/api 0.15.14 → 0.15.15

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.
@@ -1,7 +1,7 @@
1
1
  import { RichText, mock, moderatePost } from '../src/'
2
- import { hasMutedWord } from '../src/moderation/mutewords'
2
+ import { matchMuteWords } from '../src/moderation/mutewords'
3
3
 
4
- describe(`hasMutedWord`, () => {
4
+ describe(`matchMuteWords`, () => {
5
5
  describe(`tags`, () => {
6
6
  it(`match: outline tag`, () => {
7
7
  const rt = new RichText({
@@ -9,16 +9,19 @@ describe(`hasMutedWord`, () => {
9
9
  })
10
10
  rt.detectFacetsWithoutResolution()
11
11
 
12
- const match = hasMutedWord({
13
- mutedWords: [
14
- { value: 'outlineTag', targets: ['tag'], actorTarget: 'all' },
15
- ],
12
+ const muteWord = {
13
+ value: 'outlineTag',
14
+ targets: ['tag'],
15
+ actorTarget: 'all',
16
+ }
17
+ const match = matchMuteWords({
18
+ mutedWords: [muteWord],
16
19
  text: rt.text,
17
20
  facets: rt.facets,
18
21
  outlineTags: ['outlineTag'],
19
22
  })
20
23
 
21
- expect(match).toBe(true)
24
+ expect(match).toEqual([{ word: muteWord, predicate: muteWord.value }])
22
25
  })
23
26
 
24
27
  it(`match: inline tag`, () => {
@@ -27,16 +30,19 @@ describe(`hasMutedWord`, () => {
27
30
  })
28
31
  rt.detectFacetsWithoutResolution()
29
32
 
30
- const match = hasMutedWord({
31
- mutedWords: [
32
- { value: 'inlineTag', targets: ['tag'], actorTarget: 'all' },
33
- ],
33
+ const muteWord = {
34
+ value: 'inlineTag',
35
+ targets: ['tag'],
36
+ actorTarget: 'all',
37
+ }
38
+ const match = matchMuteWords({
39
+ mutedWords: [muteWord],
34
40
  text: rt.text,
35
41
  facets: rt.facets,
36
42
  outlineTags: ['outlineTag'],
37
43
  })
38
44
 
39
- expect(match).toBe(true)
45
+ expect(match).toEqual([{ word: muteWord, predicate: muteWord.value }])
40
46
  })
41
47
 
42
48
  it(`match: content target matches inline tag`, () => {
@@ -45,7 +51,7 @@ describe(`hasMutedWord`, () => {
45
51
  })
46
52
  rt.detectFacetsWithoutResolution()
47
53
 
48
- const match = hasMutedWord({
54
+ const match = matchMuteWords({
49
55
  mutedWords: [
50
56
  { value: 'inlineTag', targets: ['content'], actorTarget: 'all' },
51
57
  ],
@@ -54,7 +60,7 @@ describe(`hasMutedWord`, () => {
54
60
  outlineTags: ['outlineTag'],
55
61
  })
56
62
 
57
- expect(match).toBe(true)
63
+ expect(match).toBeTruthy()
58
64
  })
59
65
 
60
66
  it(`no match: only tag targets`, () => {
@@ -63,7 +69,7 @@ describe(`hasMutedWord`, () => {
63
69
  })
64
70
  rt.detectFacetsWithoutResolution()
65
71
 
66
- const match = hasMutedWord({
72
+ const match = matchMuteWords({
67
73
  mutedWords: [
68
74
  { value: 'inlineTag', targets: ['tag'], actorTarget: 'all' },
69
75
  ],
@@ -72,7 +78,7 @@ describe(`hasMutedWord`, () => {
72
78
  outlineTags: [],
73
79
  })
74
80
 
75
- expect(match).toBe(false)
81
+ expect(match).toBeUndefined()
76
82
  })
77
83
  })
78
84
 
@@ -86,14 +92,15 @@ describe(`hasMutedWord`, () => {
86
92
  })
87
93
  rt.detectFacetsWithoutResolution()
88
94
 
89
- const match = hasMutedWord({
90
- mutedWords: [{ value: '希', targets: ['content'], actorTarget: 'all' }],
95
+ const muteWord = { value: '希', targets: ['content'], actorTarget: 'all' }
96
+ const match = matchMuteWords({
97
+ mutedWords: [muteWord],
91
98
  text: rt.text,
92
99
  facets: rt.facets,
93
100
  outlineTags: [],
94
101
  })
95
102
 
96
- expect(match).toBe(true)
103
+ expect(match).toEqual([{ word: muteWord, predicate: muteWord.value }])
97
104
  })
98
105
 
99
106
  it(`match: single char with length > 1 ☠︎`, () => {
@@ -102,7 +109,7 @@ describe(`hasMutedWord`, () => {
102
109
  })
103
110
  rt.detectFacetsWithoutResolution()
104
111
 
105
- const match = hasMutedWord({
112
+ const match = matchMuteWords({
106
113
  mutedWords: [
107
114
  { value: '☠︎', targets: ['content'], actorTarget: 'all' },
108
115
  ],
@@ -111,7 +118,7 @@ describe(`hasMutedWord`, () => {
111
118
  outlineTags: [],
112
119
  })
113
120
 
114
- expect(match).toBe(true)
121
+ expect(match).toBeTruthy()
115
122
  })
116
123
 
117
124
  it(`no match: long muted word, short post`, () => {
@@ -120,7 +127,7 @@ describe(`hasMutedWord`, () => {
120
127
  })
121
128
  rt.detectFacetsWithoutResolution()
122
129
 
123
- const match = hasMutedWord({
130
+ const match = matchMuteWords({
124
131
  mutedWords: [
125
132
  { value: 'politics', targets: ['content'], actorTarget: 'all' },
126
133
  ],
@@ -129,7 +136,7 @@ describe(`hasMutedWord`, () => {
129
136
  outlineTags: [],
130
137
  })
131
138
 
132
- expect(match).toBe(false)
139
+ expect(match).toBeUndefined()
133
140
  })
134
141
 
135
142
  it(`match: exact text`, () => {
@@ -138,7 +145,7 @@ describe(`hasMutedWord`, () => {
138
145
  })
139
146
  rt.detectFacetsWithoutResolution()
140
147
 
141
- const match = hasMutedWord({
148
+ const match = matchMuteWords({
142
149
  mutedWords: [
143
150
  { value: 'javascript', targets: ['content'], actorTarget: 'all' },
144
151
  ],
@@ -147,7 +154,7 @@ describe(`hasMutedWord`, () => {
147
154
  outlineTags: [],
148
155
  })
149
156
 
150
- expect(match).toBe(true)
157
+ expect(match).toBeTruthy()
151
158
  })
152
159
  })
153
160
 
@@ -158,16 +165,19 @@ describe(`hasMutedWord`, () => {
158
165
  })
159
166
  rt.detectFacetsWithoutResolution()
160
167
 
161
- const match = hasMutedWord({
162
- mutedWords: [
163
- { value: 'javascript', targets: ['content'], actorTarget: 'all' },
164
- ],
168
+ const muteWord = {
169
+ value: 'javascript',
170
+ targets: ['content'],
171
+ actorTarget: 'all',
172
+ }
173
+ const match = matchMuteWords({
174
+ mutedWords: [muteWord],
165
175
  text: rt.text,
166
176
  facets: rt.facets,
167
177
  outlineTags: [],
168
178
  })
169
179
 
170
- expect(match).toBe(true)
180
+ expect(match).toEqual([{ word: muteWord, predicate: muteWord.value }])
171
181
  })
172
182
 
173
183
  it(`no match: partial word`, () => {
@@ -176,14 +186,14 @@ describe(`hasMutedWord`, () => {
176
186
  })
177
187
  rt.detectFacetsWithoutResolution()
178
188
 
179
- const match = hasMutedWord({
189
+ const match = matchMuteWords({
180
190
  mutedWords: [{ value: 'ai', targets: ['content'], actorTarget: 'all' }],
181
191
  text: rt.text,
182
192
  facets: rt.facets,
183
193
  outlineTags: [],
184
194
  })
185
195
 
186
- expect(match).toBe(false)
196
+ expect(match).toBeUndefined()
187
197
  })
188
198
 
189
199
  it(`match: multiline`, () => {
@@ -192,7 +202,7 @@ describe(`hasMutedWord`, () => {
192
202
  })
193
203
  rt.detectFacetsWithoutResolution()
194
204
 
195
- const match = hasMutedWord({
205
+ const match = matchMuteWords({
196
206
  mutedWords: [
197
207
  { value: 'brain', targets: ['content'], actorTarget: 'all' },
198
208
  ],
@@ -201,7 +211,7 @@ describe(`hasMutedWord`, () => {
201
211
  outlineTags: [],
202
212
  })
203
213
 
204
- expect(match).toBe(true)
214
+ expect(match).toBeTruthy()
205
215
  })
206
216
 
207
217
  it(`match: :)`, () => {
@@ -210,14 +220,14 @@ describe(`hasMutedWord`, () => {
210
220
  })
211
221
  rt.detectFacetsWithoutResolution()
212
222
 
213
- const match = hasMutedWord({
223
+ const match = matchMuteWords({
214
224
  mutedWords: [{ value: `:)`, targets: ['content'], actorTarget: 'all' }],
215
225
  text: rt.text,
216
226
  facets: rt.facets,
217
227
  outlineTags: [],
218
228
  })
219
229
 
220
- expect(match).toBe(true)
230
+ expect(match).toBeTruthy()
221
231
  })
222
232
  })
223
233
 
@@ -229,7 +239,7 @@ describe(`hasMutedWord`, () => {
229
239
  rt.detectFacetsWithoutResolution()
230
240
 
231
241
  it(`match: yay!`, () => {
232
- const match = hasMutedWord({
242
+ const match = matchMuteWords({
233
243
  mutedWords: [
234
244
  { value: 'yay!', targets: ['content'], actorTarget: 'all' },
235
245
  ],
@@ -238,11 +248,11 @@ describe(`hasMutedWord`, () => {
238
248
  outlineTags: [],
239
249
  })
240
250
 
241
- expect(match).toBe(true)
251
+ expect(match).toBeTruthy()
242
252
  })
243
253
 
244
254
  it(`match: yay`, () => {
245
- const match = hasMutedWord({
255
+ const match = matchMuteWords({
246
256
  mutedWords: [
247
257
  { value: 'yay', targets: ['content'], actorTarget: 'all' },
248
258
  ],
@@ -251,7 +261,7 @@ describe(`hasMutedWord`, () => {
251
261
  outlineTags: [],
252
262
  })
253
263
 
254
- expect(match).toBe(true)
264
+ expect(match).toBeTruthy()
255
265
  })
256
266
  })
257
267
 
@@ -262,7 +272,7 @@ describe(`hasMutedWord`, () => {
262
272
  rt.detectFacetsWithoutResolution()
263
273
 
264
274
  it(`match: y!ppee`, () => {
265
- const match = hasMutedWord({
275
+ const match = matchMuteWords({
266
276
  mutedWords: [
267
277
  { value: 'y!ppee', targets: ['content'], actorTarget: 'all' },
268
278
  ],
@@ -271,12 +281,12 @@ describe(`hasMutedWord`, () => {
271
281
  outlineTags: [],
272
282
  })
273
283
 
274
- expect(match).toBe(true)
284
+ expect(match).toBeTruthy()
275
285
  })
276
286
 
277
287
  // single exclamation point, source has double
278
288
  it(`no match: y!ppee!`, () => {
279
- const match = hasMutedWord({
289
+ const match = matchMuteWords({
280
290
  mutedWords: [
281
291
  { value: 'y!ppee!', targets: ['content'], actorTarget: 'all' },
282
292
  ],
@@ -285,7 +295,7 @@ describe(`hasMutedWord`, () => {
285
295
  outlineTags: [],
286
296
  })
287
297
 
288
- expect(match).toBe(true)
298
+ expect(match).toBeTruthy()
289
299
  })
290
300
  })
291
301
 
@@ -296,7 +306,7 @@ describe(`hasMutedWord`, () => {
296
306
  rt.detectFacetsWithoutResolution()
297
307
 
298
308
  it(`match: Bluesky's`, () => {
299
- const match = hasMutedWord({
309
+ const match = matchMuteWords({
300
310
  mutedWords: [
301
311
  { value: `Bluesky's`, targets: ['content'], actorTarget: 'all' },
302
312
  ],
@@ -305,11 +315,11 @@ describe(`hasMutedWord`, () => {
305
315
  outlineTags: [],
306
316
  })
307
317
 
308
- expect(match).toBe(true)
318
+ expect(match).toBeTruthy()
309
319
  })
310
320
 
311
321
  it(`match: Bluesky`, () => {
312
- const match = hasMutedWord({
322
+ const match = matchMuteWords({
313
323
  mutedWords: [
314
324
  { value: 'Bluesky', targets: ['content'], actorTarget: 'all' },
315
325
  ],
@@ -318,11 +328,11 @@ describe(`hasMutedWord`, () => {
318
328
  outlineTags: [],
319
329
  })
320
330
 
321
- expect(match).toBe(true)
331
+ expect(match).toBeTruthy()
322
332
  })
323
333
 
324
334
  it(`match: bluesky`, () => {
325
- const match = hasMutedWord({
335
+ const match = matchMuteWords({
326
336
  mutedWords: [
327
337
  { value: 'bluesky', targets: ['content'], actorTarget: 'all' },
328
338
  ],
@@ -331,11 +341,11 @@ describe(`hasMutedWord`, () => {
331
341
  outlineTags: [],
332
342
  })
333
343
 
334
- expect(match).toBe(true)
344
+ expect(match).toBeTruthy()
335
345
  })
336
346
 
337
347
  it(`match: blueskys`, () => {
338
- const match = hasMutedWord({
348
+ const match = matchMuteWords({
339
349
  mutedWords: [
340
350
  { value: 'blueskys', targets: ['content'], actorTarget: 'all' },
341
351
  ],
@@ -344,7 +354,7 @@ describe(`hasMutedWord`, () => {
344
354
  outlineTags: [],
345
355
  })
346
356
 
347
- expect(match).toBe(true)
357
+ expect(match).toBeTruthy()
348
358
  })
349
359
  })
350
360
 
@@ -355,7 +365,7 @@ describe(`hasMutedWord`, () => {
355
365
  rt.detectFacetsWithoutResolution()
356
366
 
357
367
  it(`match: S@assy`, () => {
358
- const match = hasMutedWord({
368
+ const match = matchMuteWords({
359
369
  mutedWords: [
360
370
  { value: 'S@assy', targets: ['content'], actorTarget: 'all' },
361
371
  ],
@@ -364,11 +374,11 @@ describe(`hasMutedWord`, () => {
364
374
  outlineTags: [],
365
375
  })
366
376
 
367
- expect(match).toBe(true)
377
+ expect(match).toBeTruthy()
368
378
  })
369
379
 
370
380
  it(`match: s@assy`, () => {
371
- const match = hasMutedWord({
381
+ const match = matchMuteWords({
372
382
  mutedWords: [
373
383
  { value: 's@assy', targets: ['content'], actorTarget: 'all' },
374
384
  ],
@@ -377,7 +387,7 @@ describe(`hasMutedWord`, () => {
377
387
  outlineTags: [],
378
388
  })
379
389
 
380
- expect(match).toBe(true)
390
+ expect(match).toBeTruthy()
381
391
  })
382
392
  })
383
393
 
@@ -389,7 +399,7 @@ describe(`hasMutedWord`, () => {
389
399
 
390
400
  // case insensitive
391
401
  it(`match: new york times`, () => {
392
- const match = hasMutedWord({
402
+ const match = matchMuteWords({
393
403
  mutedWords: [
394
404
  {
395
405
  value: 'new york times',
@@ -402,7 +412,7 @@ describe(`hasMutedWord`, () => {
402
412
  outlineTags: [],
403
413
  })
404
414
 
405
- expect(match).toBe(true)
415
+ expect(match).toBeTruthy()
406
416
  })
407
417
  })
408
418
 
@@ -413,7 +423,7 @@ describe(`hasMutedWord`, () => {
413
423
  rt.detectFacetsWithoutResolution()
414
424
 
415
425
  it(`match: !command`, () => {
416
- const match = hasMutedWord({
426
+ const match = matchMuteWords({
417
427
  mutedWords: [
418
428
  { value: `!command`, targets: ['content'], actorTarget: 'all' },
419
429
  ],
@@ -422,11 +432,11 @@ describe(`hasMutedWord`, () => {
422
432
  outlineTags: [],
423
433
  })
424
434
 
425
- expect(match).toBe(true)
435
+ expect(match).toBeTruthy()
426
436
  })
427
437
 
428
438
  it(`match: command`, () => {
429
- const match = hasMutedWord({
439
+ const match = matchMuteWords({
430
440
  mutedWords: [
431
441
  { value: `command`, targets: ['content'], actorTarget: 'all' },
432
442
  ],
@@ -435,7 +445,7 @@ describe(`hasMutedWord`, () => {
435
445
  outlineTags: [],
436
446
  })
437
447
 
438
- expect(match).toBe(true)
448
+ expect(match).toBeTruthy()
439
449
  })
440
450
 
441
451
  it(`no match: !command`, () => {
@@ -444,7 +454,7 @@ describe(`hasMutedWord`, () => {
444
454
  })
445
455
  rt.detectFacetsWithoutResolution()
446
456
 
447
- const match = hasMutedWord({
457
+ const match = matchMuteWords({
448
458
  mutedWords: [
449
459
  { value: `!command`, targets: ['content'], actorTarget: 'all' },
450
460
  ],
@@ -453,40 +463,40 @@ describe(`hasMutedWord`, () => {
453
463
  outlineTags: [],
454
464
  })
455
465
 
456
- expect(match).toBe(false)
466
+ expect(match).toBeUndefined()
457
467
  })
458
468
  })
459
469
 
460
- describe(`e/acc`, () => {
470
+ describe(`and/or`, () => {
461
471
  const rt = new RichText({
462
- text: `I'm e/acc pilled`,
472
+ text: `Tomatoes are fruits and/or vegetables`,
463
473
  })
464
474
  rt.detectFacetsWithoutResolution()
465
475
 
466
- it(`match: e/acc`, () => {
467
- const match = hasMutedWord({
476
+ it(`match: and/or`, () => {
477
+ const match = matchMuteWords({
468
478
  mutedWords: [
469
- { value: `e/acc`, targets: ['content'], actorTarget: 'all' },
479
+ { value: `and/or`, targets: ['content'], actorTarget: 'all' },
470
480
  ],
471
481
  text: rt.text,
472
482
  facets: rt.facets,
473
483
  outlineTags: [],
474
484
  })
475
485
 
476
- expect(match).toBe(true)
486
+ expect(match).toBeTruthy()
477
487
  })
478
488
 
479
- it(`match: acc`, () => {
480
- const match = hasMutedWord({
489
+ it(`no match: Andor`, () => {
490
+ const match = matchMuteWords({
481
491
  mutedWords: [
482
- { value: `acc`, targets: ['content'], actorTarget: 'all' },
492
+ { value: `Andor`, targets: ['content'], actorTarget: 'all' },
483
493
  ],
484
494
  text: rt.text,
485
495
  facets: rt.facets,
486
496
  outlineTags: [],
487
497
  })
488
498
 
489
- expect(match).toBe(true)
499
+ expect(match).toBeUndefined()
490
500
  })
491
501
  })
492
502
 
@@ -497,7 +507,7 @@ describe(`hasMutedWord`, () => {
497
507
  rt.detectFacetsWithoutResolution()
498
508
 
499
509
  it(`match: super-bad`, () => {
500
- const match = hasMutedWord({
510
+ const match = matchMuteWords({
501
511
  mutedWords: [
502
512
  { value: `super-bad`, targets: ['content'], actorTarget: 'all' },
503
513
  ],
@@ -506,11 +516,11 @@ describe(`hasMutedWord`, () => {
506
516
  outlineTags: [],
507
517
  })
508
518
 
509
- expect(match).toBe(true)
519
+ expect(match).toBeTruthy()
510
520
  })
511
521
 
512
522
  it(`match: super`, () => {
513
- const match = hasMutedWord({
523
+ const match = matchMuteWords({
514
524
  mutedWords: [
515
525
  { value: `super`, targets: ['content'], actorTarget: 'all' },
516
526
  ],
@@ -519,11 +529,11 @@ describe(`hasMutedWord`, () => {
519
529
  outlineTags: [],
520
530
  })
521
531
 
522
- expect(match).toBe(true)
532
+ expect(match).toBeTruthy()
523
533
  })
524
534
 
525
535
  it(`match: bad`, () => {
526
- const match = hasMutedWord({
536
+ const match = matchMuteWords({
527
537
  mutedWords: [
528
538
  { value: `bad`, targets: ['content'], actorTarget: 'all' },
529
539
  ],
@@ -532,11 +542,11 @@ describe(`hasMutedWord`, () => {
532
542
  outlineTags: [],
533
543
  })
534
544
 
535
- expect(match).toBe(true)
545
+ expect(match).toBeTruthy()
536
546
  })
537
547
 
538
548
  it(`match: super bad`, () => {
539
- const match = hasMutedWord({
549
+ const match = matchMuteWords({
540
550
  mutedWords: [
541
551
  { value: `super bad`, targets: ['content'], actorTarget: 'all' },
542
552
  ],
@@ -545,11 +555,11 @@ describe(`hasMutedWord`, () => {
545
555
  outlineTags: [],
546
556
  })
547
557
 
548
- expect(match).toBe(true)
558
+ expect(match).toBeTruthy()
549
559
  })
550
560
 
551
561
  it(`match: superbad`, () => {
552
- const match = hasMutedWord({
562
+ const match = matchMuteWords({
553
563
  mutedWords: [
554
564
  { value: `superbad`, targets: ['content'], actorTarget: 'all' },
555
565
  ],
@@ -558,7 +568,7 @@ describe(`hasMutedWord`, () => {
558
568
  outlineTags: [],
559
569
  })
560
570
 
561
- expect(match).toBe(true)
571
+ expect(match).toBeTruthy()
562
572
  })
563
573
  })
564
574
 
@@ -569,7 +579,7 @@ describe(`hasMutedWord`, () => {
569
579
  rt.detectFacetsWithoutResolution()
570
580
 
571
581
  it(`match: idk what this would be`, () => {
572
- const match = hasMutedWord({
582
+ const match = matchMuteWords({
573
583
  mutedWords: [
574
584
  {
575
585
  value: `idk what this would be`,
@@ -582,12 +592,12 @@ describe(`hasMutedWord`, () => {
582
592
  outlineTags: [],
583
593
  })
584
594
 
585
- expect(match).toBe(true)
595
+ expect(match).toBeTruthy()
586
596
  })
587
597
 
588
598
  it(`no match: idk what this would be for`, () => {
589
599
  // extra word
590
- const match = hasMutedWord({
600
+ const match = matchMuteWords({
591
601
  mutedWords: [
592
602
  {
593
603
  value: `idk what this would be for`,
@@ -600,12 +610,12 @@ describe(`hasMutedWord`, () => {
600
610
  outlineTags: [],
601
611
  })
602
612
 
603
- expect(match).toBe(false)
613
+ expect(match).toBeUndefined()
604
614
  })
605
615
 
606
616
  it(`match: idk`, () => {
607
617
  // extra word
608
- const match = hasMutedWord({
618
+ const match = matchMuteWords({
609
619
  mutedWords: [
610
620
  { value: `idk`, targets: ['content'], actorTarget: 'all' },
611
621
  ],
@@ -614,11 +624,11 @@ describe(`hasMutedWord`, () => {
614
624
  outlineTags: [],
615
625
  })
616
626
 
617
- expect(match).toBe(true)
627
+ expect(match).toBeTruthy()
618
628
  })
619
629
 
620
630
  it(`match: idkwhatthiswouldbe`, () => {
621
- const match = hasMutedWord({
631
+ const match = matchMuteWords({
622
632
  mutedWords: [
623
633
  {
624
634
  value: `idkwhatthiswouldbe`,
@@ -631,7 +641,7 @@ describe(`hasMutedWord`, () => {
631
641
  outlineTags: [],
632
642
  })
633
643
 
634
- expect(match).toBe(true)
644
+ expect(match).toBeTruthy()
635
645
  })
636
646
  })
637
647
 
@@ -642,7 +652,7 @@ describe(`hasMutedWord`, () => {
642
652
  rt.detectFacetsWithoutResolution()
643
653
 
644
654
  it(`match: context(iykyk)`, () => {
645
- const match = hasMutedWord({
655
+ const match = matchMuteWords({
646
656
  mutedWords: [
647
657
  {
648
658
  value: `context(iykyk)`,
@@ -655,11 +665,11 @@ describe(`hasMutedWord`, () => {
655
665
  outlineTags: [],
656
666
  })
657
667
 
658
- expect(match).toBe(true)
668
+ expect(match).toBeTruthy()
659
669
  })
660
670
 
661
671
  it(`match: context`, () => {
662
- const match = hasMutedWord({
672
+ const match = matchMuteWords({
663
673
  mutedWords: [
664
674
  { value: `context`, targets: ['content'], actorTarget: 'all' },
665
675
  ],
@@ -668,11 +678,11 @@ describe(`hasMutedWord`, () => {
668
678
  outlineTags: [],
669
679
  })
670
680
 
671
- expect(match).toBe(true)
681
+ expect(match).toBeTruthy()
672
682
  })
673
683
 
674
684
  it(`match: iykyk`, () => {
675
- const match = hasMutedWord({
685
+ const match = matchMuteWords({
676
686
  mutedWords: [
677
687
  { value: `iykyk`, targets: ['content'], actorTarget: 'all' },
678
688
  ],
@@ -681,11 +691,11 @@ describe(`hasMutedWord`, () => {
681
691
  outlineTags: [],
682
692
  })
683
693
 
684
- expect(match).toBe(true)
694
+ expect(match).toBeTruthy()
685
695
  })
686
696
 
687
697
  it(`match: (iykyk)`, () => {
688
- const match = hasMutedWord({
698
+ const match = matchMuteWords({
689
699
  mutedWords: [
690
700
  { value: `(iykyk)`, targets: ['content'], actorTarget: 'all' },
691
701
  ],
@@ -694,7 +704,7 @@ describe(`hasMutedWord`, () => {
694
704
  outlineTags: [],
695
705
  })
696
706
 
697
- expect(match).toBe(true)
707
+ expect(match).toBeTruthy()
698
708
  })
699
709
  })
700
710
 
@@ -705,7 +715,7 @@ describe(`hasMutedWord`, () => {
705
715
  rt.detectFacetsWithoutResolution()
706
716
 
707
717
  it(`match: 🦋`, () => {
708
- const match = hasMutedWord({
718
+ const match = matchMuteWords({
709
719
  mutedWords: [
710
720
  { value: `🦋`, targets: ['content'], actorTarget: 'all' },
711
721
  ],
@@ -714,7 +724,7 @@ describe(`hasMutedWord`, () => {
714
724
  outlineTags: [],
715
725
  })
716
726
 
717
- expect(match).toBe(true)
727
+ expect(match).toBeTruthy()
718
728
  })
719
729
  })
720
730
  })
@@ -727,7 +737,7 @@ describe(`hasMutedWord`, () => {
727
737
  rt.detectFacetsWithoutResolution()
728
738
 
729
739
  it(`match: stop worrying`, () => {
730
- const match = hasMutedWord({
740
+ const match = matchMuteWords({
731
741
  mutedWords: [
732
742
  {
733
743
  value: 'stop worrying',
@@ -740,11 +750,11 @@ describe(`hasMutedWord`, () => {
740
750
  outlineTags: [],
741
751
  })
742
752
 
743
- expect(match).toBe(true)
753
+ expect(match).toBeTruthy()
744
754
  })
745
755
 
746
756
  it(`match: turtles, or how`, () => {
747
- const match = hasMutedWord({
757
+ const match = matchMuteWords({
748
758
  mutedWords: [
749
759
  {
750
760
  value: 'turtles, or how',
@@ -757,7 +767,7 @@ describe(`hasMutedWord`, () => {
757
767
  outlineTags: [],
758
768
  })
759
769
 
760
- expect(match).toBe(true)
770
+ expect(match).toBeTruthy()
761
771
  })
762
772
  })
763
773
  })
@@ -772,7 +782,7 @@ describe(`hasMutedWord`, () => {
772
782
 
773
783
  // internet
774
784
  it(`match: インターネット`, () => {
775
- const match = hasMutedWord({
785
+ const match = matchMuteWords({
776
786
  mutedWords: [
777
787
  {
778
788
  value: 'インターネット',
@@ -786,14 +796,14 @@ describe(`hasMutedWord`, () => {
786
796
  languages: ['ja'],
787
797
  })
788
798
 
789
- expect(match).toBe(true)
799
+ expect(match).toBeTruthy()
790
800
  })
791
801
  })
792
802
  })
793
803
 
794
804
  describe(`facet with multiple features`, () => {
795
805
  it(`multiple tags`, () => {
796
- const match = hasMutedWord({
806
+ const match = matchMuteWords({
797
807
  mutedWords: [
798
808
  { value: 'bad', targets: ['content'], actorTarget: 'all' },
799
809
  ],
@@ -817,11 +827,11 @@ describe(`hasMutedWord`, () => {
817
827
  },
818
828
  ],
819
829
  })
820
- expect(match).toBe(true)
830
+ expect(match).toBeTruthy()
821
831
  })
822
832
 
823
833
  it(`other features`, () => {
824
- const match = hasMutedWord({
834
+ const match = matchMuteWords({
825
835
  mutedWords: [
826
836
  { value: 'bad', targets: ['content'], actorTarget: 'all' },
827
837
  ],
@@ -846,7 +856,7 @@ describe(`hasMutedWord`, () => {
846
856
  },
847
857
  ],
848
858
  })
849
- expect(match).toBe(true)
859
+ expect(match).toBeTruthy()
850
860
  })
851
861
  })
852
862
 
@@ -1078,4 +1088,35 @@ describe(`hasMutedWord`, () => {
1078
1088
  expect(res.causes[0].type).toBe('mute-word')
1079
1089
  })
1080
1090
  })
1091
+
1092
+ describe(`returning MuteWordMatch`, () => {
1093
+ it(`matches all`, () => {
1094
+ const rt = new RichText({
1095
+ text: `This is a post about javascript`,
1096
+ })
1097
+ rt.detectFacetsWithoutResolution()
1098
+
1099
+ const muteWord1 = {
1100
+ value: 'post',
1101
+ targets: ['content'],
1102
+ actorTarget: 'all',
1103
+ }
1104
+ const muteWord2 = {
1105
+ value: 'javascript',
1106
+ targets: ['content'],
1107
+ actorTarget: 'all',
1108
+ }
1109
+ const match = matchMuteWords({
1110
+ mutedWords: [muteWord1, muteWord2],
1111
+ text: rt.text,
1112
+ facets: rt.facets,
1113
+ outlineTags: [],
1114
+ })
1115
+
1116
+ expect(match).toEqual([
1117
+ { word: muteWord1, predicate: muteWord1.value },
1118
+ { word: muteWord2, predicate: muteWord2.value },
1119
+ ])
1120
+ })
1121
+ })
1081
1122
  })