Skip to content

Commit

Permalink
Don't mute your own posts (#3037)
Browse files Browse the repository at this point in the history
* Don't mute your own posts.

* fix and add tests
  • Loading branch information
haileyok authored Feb 29, 2024
1 parent 2440975 commit a35976c
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
89 changes: 89 additions & 0 deletions src/lib/__tests__/moderatePost_wrapped.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: ['outlineTag'],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -32,6 +33,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: ['outlineTag'],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -48,6 +50,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: ['outlineTag'],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -64,6 +67,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(false)
Expand All @@ -85,6 +89,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -101,6 +106,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(false)
Expand All @@ -117,6 +123,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -135,6 +142,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -151,6 +159,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(false)
Expand All @@ -167,6 +176,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -183,6 +193,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -202,6 +213,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -213,6 +225,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -231,6 +244,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -243,6 +257,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -261,6 +276,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -272,6 +288,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -291,6 +308,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -309,6 +327,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -320,6 +339,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -336,6 +356,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(false)
Expand All @@ -354,6 +375,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -365,6 +387,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -383,6 +406,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -394,6 +418,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -405,6 +430,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -416,6 +442,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(false)
Expand All @@ -434,6 +461,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -448,6 +476,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(false)
Expand All @@ -460,6 +489,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -471,6 +501,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(false)
Expand All @@ -489,6 +520,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -500,6 +532,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -511,6 +544,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -522,6 +556,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -540,6 +575,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -560,6 +596,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -571,6 +608,7 @@ describe(`hasMutedWord`, () => {
text: rt.text,
facets: rt.facets,
outlineTags: [],
isOwnPost: false,
})

expect(match).toBe(true)
Expand All @@ -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)
})
})
})
Loading

0 comments on commit a35976c

Please sign in to comment.