diff options
author | Hailey <me@haileyok.com> | 2024-02-28 18:41:23 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 18:41:23 -0800 |
commit | a35976cdc9b6467ad8b6e0c4ff46ba684fee9064 (patch) | |
tree | ed9a990c3b21963948d763630e80cab8967e0638 /src/lib/__tests__/moderatePost_wrapped.test.ts | |
parent | 2440975bd224e4c39b633b21c461cb8b8d3c1f9b (diff) | |
download | voidsky-a35976cdc9b6467ad8b6e0c4ff46ba684fee9064.tar.zst |
Don't mute your own posts (#3037)
* Don't mute your own posts. * fix and add tests
Diffstat (limited to 'src/lib/__tests__/moderatePost_wrapped.test.ts')
-rw-r--r-- | src/lib/__tests__/moderatePost_wrapped.test.ts | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/lib/__tests__/moderatePost_wrapped.test.ts b/src/lib/__tests__/moderatePost_wrapped.test.ts index c35c1ef77..45566281a 100644 --- a/src/lib/__tests__/moderatePost_wrapped.test.ts +++ b/src/lib/__tests__/moderatePost_wrapped.test.ts @@ -16,6 +16,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: ['outlineTag'], + isOwnPost: false, }) expect(match).toBe(true) @@ -32,6 +33,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: ['outlineTag'], + isOwnPost: false, }) expect(match).toBe(true) @@ -48,6 +50,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: ['outlineTag'], + isOwnPost: false, }) expect(match).toBe(true) @@ -64,6 +67,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(false) @@ -85,6 +89,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -101,6 +106,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(false) @@ -117,6 +123,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -135,6 +142,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -151,6 +159,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(false) @@ -167,6 +176,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -183,6 +193,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -202,6 +213,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -213,6 +225,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -231,6 +244,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -243,6 +257,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -261,6 +276,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -272,6 +288,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -291,6 +308,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -309,6 +327,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -320,6 +339,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -336,6 +356,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(false) @@ -354,6 +375,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -365,6 +387,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -383,6 +406,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -394,6 +418,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -405,6 +430,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -416,6 +442,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(false) @@ -434,6 +461,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -448,6 +476,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(false) @@ -460,6 +489,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -471,6 +501,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(false) @@ -489,6 +520,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -500,6 +532,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -511,6 +544,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -522,6 +556,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -540,6 +575,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -560,6 +596,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -571,6 +608,7 @@ describe(`hasMutedWord`, () => { text: rt.text, facets: rt.facets, outlineTags: [], + isOwnPost: false, }) expect(match).toBe(true) @@ -594,10 +632,61 @@ describe(`hasMutedWord`, () => { facets: rt.facets, outlineTags: [], languages: ['ja'], + isOwnPost: false, }) expect(match).toBe(true) }) }) }) + + describe(`doesn't mute own post`, () => { + it(`does mute if it isn't own post`, () => { + const rt = new RichText({ + text: `Mute words!`, + }) + + const match = hasMutedWord({ + mutedWords: [{value: 'words', targets: ['content']}], + text: rt.text, + facets: rt.facets, + outlineTags: [], + isOwnPost: false, + }) + + expect(match).toBe(true) + }) + + it(`doesn't mute own post when muted word is in text`, () => { + const rt = new RichText({ + text: `Mute words!`, + }) + + const match = hasMutedWord({ + mutedWords: [{value: 'words', targets: ['content']}], + text: rt.text, + facets: rt.facets, + outlineTags: [], + isOwnPost: true, + }) + + expect(match).toBe(false) + }) + + it(`doesn't mute own post when muted word is in tags`, () => { + const rt = new RichText({ + text: `Mute #words!`, + }) + + const match = hasMutedWord({ + mutedWords: [{value: 'words', targets: ['tags']}], + text: rt.text, + facets: rt.facets, + outlineTags: [], + isOwnPost: true, + }) + + expect(match).toBe(false) + }) + }) }) |