-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prevent unecessary sync (#102)
- Loading branch information
1 parent
cad44a2
commit 4ea135f
Showing
5 changed files
with
104 additions
and
40 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
src/helpers/cache/migrations/helpers/prevent-migration-on-wrong-version.ts
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const preventMigrationOnWrongVersion = ( | ||
outdatedCache: NonNullable<unknown>, | ||
requiredVersion: string, | ||
) => | ||
(outdatedCache as NonNullable<unknown & { version: string }>).version !== | ||
requiredVersion; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Tweet } from "@the-convocation/twitter-scraper"; | ||
|
||
import { tweetFormatter } from "../tweet-formatter.js"; | ||
|
||
jest.mock("../format-tweet-text.js", () => { | ||
return { | ||
formatTweetText: jest | ||
.fn() | ||
.mockImplementation((t: Tweet) => `formatted:${t.text}`), | ||
}; | ||
}); | ||
|
||
describe("tweetFormatter", () => { | ||
it("should properly format the give tweet", () => { | ||
const result = tweetFormatter({ | ||
text: "text", | ||
timestamp: 966236400, | ||
} as Tweet); | ||
|
||
expect(result).toStrictEqual({ | ||
text: "formatted:text", | ||
timestamp: 966236400000, | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Tweet } from "@the-convocation/twitter-scraper"; | ||
|
||
import { formatTweetText } from "./format-tweet-text.js"; | ||
|
||
export const tweetFormatter = (tweet: Tweet): Tweet => { | ||
return { | ||
...tweet, | ||
timestamp: (tweet.timestamp ?? 0) * 1000, | ||
text: formatTweetText(tweet), | ||
}; | ||
}; |
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