generated from NEARBuilders/project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
e1cf914
commit 097bc06
Showing
23 changed files
with
457 additions
and
325 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build | ||
coverage | ||
node_modules | ||
.turbo | ||
.next | ||
.docusaurus |
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,38 +1,65 @@ | ||
import { mock } from 'bun:test'; | ||
import { TwitterSubmission } from '../../types/twitter'; | ||
import { mock } from "bun:test"; | ||
import { TwitterSubmission } from "../../types/twitter"; | ||
|
||
// Define the database interface to match our schema | ||
interface DbInterface { | ||
upsertFeed: (feed: { id: string; name: string; description?: string }) => void; | ||
upsertFeed: (feed: { | ||
id: string; | ||
name: string; | ||
description?: string; | ||
}) => void; | ||
getDailySubmissionCount: (userId: string) => number; | ||
saveSubmission: (submission: TwitterSubmission) => void; | ||
saveSubmissionToFeed: (submissionId: string, feedId: string) => void; | ||
incrementDailySubmissionCount: (userId: string) => void; | ||
updateSubmissionAcknowledgment: (tweetId: string, acknowledgmentTweetId: string) => void; | ||
getSubmissionByAcknowledgmentTweetId: (acknowledgmentTweetId: string) => Promise<TwitterSubmission | null>; | ||
updateSubmissionAcknowledgment: ( | ||
tweetId: string, | ||
acknowledgmentTweetId: string, | ||
) => void; | ||
getSubmissionByAcknowledgmentTweetId: ( | ||
acknowledgmentTweetId: string, | ||
) => Promise<TwitterSubmission | null>; | ||
saveModerationAction: (moderation: any) => void; | ||
updateSubmissionStatus: (tweetId: string, status: "approved" | "rejected", responseTweetId: string) => void; | ||
getFeedsBySubmission: (submissionId: string) => Promise<Array<{ feedId: string }>>; | ||
updateSubmissionStatus: ( | ||
tweetId: string, | ||
status: "approved" | "rejected", | ||
responseTweetId: string, | ||
) => void; | ||
getFeedsBySubmission: ( | ||
submissionId: string, | ||
) => Promise<Array<{ feedId: string }>>; | ||
removeFromSubmissionFeed: (submissionId: string, feedId: string) => void; | ||
} | ||
|
||
// Create mock functions for each database operation | ||
export const drizzleMock = { | ||
upsertFeed: mock<DbInterface['upsertFeed']>(() => {}), | ||
getDailySubmissionCount: mock<DbInterface['getDailySubmissionCount']>(() => 0), | ||
saveSubmission: mock<DbInterface['saveSubmission']>(() => {}), | ||
saveSubmissionToFeed: mock<DbInterface['saveSubmissionToFeed']>(() => {}), | ||
incrementDailySubmissionCount: mock<DbInterface['incrementDailySubmissionCount']>(() => {}), | ||
updateSubmissionAcknowledgment: mock<DbInterface['updateSubmissionAcknowledgment']>(() => {}), | ||
getSubmissionByAcknowledgmentTweetId: mock<DbInterface['getSubmissionByAcknowledgmentTweetId']>(() => Promise.resolve(null)), | ||
saveModerationAction: mock<DbInterface['saveModerationAction']>(() => {}), | ||
updateSubmissionStatus: mock<DbInterface['updateSubmissionStatus']>(() => {}), | ||
getFeedsBySubmission: mock<DbInterface['getFeedsBySubmission']>(() => Promise.resolve([])), | ||
removeFromSubmissionFeed: mock<DbInterface['removeFromSubmissionFeed']>(() => {}), | ||
upsertFeed: mock<DbInterface["upsertFeed"]>(() => {}), | ||
getDailySubmissionCount: mock<DbInterface["getDailySubmissionCount"]>( | ||
() => 0, | ||
), | ||
saveSubmission: mock<DbInterface["saveSubmission"]>(() => {}), | ||
saveSubmissionToFeed: mock<DbInterface["saveSubmissionToFeed"]>(() => {}), | ||
incrementDailySubmissionCount: mock< | ||
DbInterface["incrementDailySubmissionCount"] | ||
>(() => {}), | ||
updateSubmissionAcknowledgment: mock< | ||
DbInterface["updateSubmissionAcknowledgment"] | ||
>(() => {}), | ||
getSubmissionByAcknowledgmentTweetId: mock< | ||
DbInterface["getSubmissionByAcknowledgmentTweetId"] | ||
>(() => Promise.resolve(null)), | ||
saveModerationAction: mock<DbInterface["saveModerationAction"]>(() => {}), | ||
updateSubmissionStatus: mock<DbInterface["updateSubmissionStatus"]>(() => {}), | ||
getFeedsBySubmission: mock<DbInterface["getFeedsBySubmission"]>(() => | ||
Promise.resolve([]), | ||
), | ||
removeFromSubmissionFeed: mock<DbInterface["removeFromSubmissionFeed"]>( | ||
() => {}, | ||
), | ||
}; | ||
|
||
// Mock the db module | ||
import { db } from '../../services/db'; | ||
import { db } from "../../services/db"; | ||
Object.assign(db, drizzleMock); | ||
|
||
export default drizzleMock; |
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
Oops, something went wrong.