-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
146 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,8 @@ node_modules/ | |
deployment/ | ||
docs/ | ||
Dockerfile | ||
|
||
# Temporary files | ||
cache*.json | ||
cookies*.json | ||
mention-mapping*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ coverage/ | |
# Temporary files | ||
cache*.json | ||
cookies*.json | ||
mention-mapping*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { describe } from "node:test"; | ||
|
||
import { Tweet } from "@the-convocation/twitter-scraper"; | ||
|
||
import { MASTODON_INSTANCE } from "../../../constants"; | ||
import { MentionMapping } from "../../../types/mentionMapping"; | ||
import { | ||
splitTextForBluesky, | ||
splitTextForMastodon, | ||
|
@@ -63,9 +66,10 @@ describe("splitTweetText", () => { | |
} as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([ | ||
|
@@ -85,9 +89,10 @@ describe("splitTweetText", () => { | |
} as unknown as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([POST_99_CHARS]); | ||
|
@@ -103,9 +108,10 @@ describe("splitTweetText", () => { | |
} as unknown as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([ | ||
|
@@ -124,9 +130,10 @@ describe("splitTweetText", () => { | |
} as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([POST_299_CHARS]); | ||
|
@@ -142,9 +149,10 @@ describe("splitTweetText", () => { | |
} as unknown as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([ | ||
|
@@ -164,9 +172,10 @@ describe("splitTweetText", () => { | |
} as unknown as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toStrictEqual([ | ||
|
@@ -191,9 +200,10 @@ describe("splitTweetText", () => { | |
} as unknown as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
|
||
|
@@ -223,9 +233,10 @@ describe("splitTweetText", () => { | |
} as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([ | ||
|
@@ -244,9 +255,10 @@ describe("splitTweetText", () => { | |
} as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([ | ||
|
@@ -271,9 +283,10 @@ describe("splitTweetText", () => { | |
} as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([ | ||
|
@@ -294,9 +307,10 @@ describe("splitTweetText", () => { | |
} as Tweet; | ||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
[], | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, []); | ||
|
||
checkChunksLengthExpectations(mastodonStatuses, blueskyStatuses); | ||
expect(mastodonStatuses).toEqual([ | ||
|
@@ -308,4 +322,32 @@ describe("splitTweetText", () => { | |
]); | ||
}); | ||
}); | ||
|
||
describe("when mention user with existing mention mapping", () => { | ||
it("should return text with the replaced mention", async () => { | ||
const tweet = { | ||
text: "Hello @ralmn45 how are you ?", | ||
mentions: [{ id: "12345", username: "ralmn45", name: "ralmn" }], | ||
} as Tweet; | ||
const mentionsMapping: MentionMapping[] = [ | ||
{ | ||
twitter: "ralmn45", | ||
mastodon: "[email protected]", | ||
bluesky: "ralmn.fr", | ||
}, | ||
]; | ||
|
||
const mastodonStatuses = await splitTextForMastodon( | ||
tweet, | ||
mentionsMapping, | ||
MASTODON_USERNAME, | ||
); | ||
const blueskyStatuses = await splitTextForBluesky(tweet, mentionsMapping); | ||
|
||
expect(mastodonStatuses).toEqual([ | ||
`Hello @[email protected] how are you ?`, | ||
]); | ||
expect(blueskyStatuses).toEqual([`Hello @ralmn.fr how are you ?`]); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.