11import { afterEach , beforeAll , expect , mock , test } from "bun:test" ;
2- import {
3- handleBumpStreak ,
4- setLastBumpNotificationTime ,
5- } from "./bump.listener.js" ;
6- import {
2+ import type {
73 Client ,
84 Message ,
95 MessageInteraction ,
106 PartialTextBasedChannelFields ,
117 User ,
128} from "discord.js" ;
9+ import { Bump } from "../../store/models/Bump.js" ;
10+ import { clearBumpsCache } from "../../store/models/bumps.js" ;
1311import {
1412 clearUserCache ,
1513 getOrCreateUserById ,
1614} from "../../store/models/DDUser.js" ;
1715import { getSequelizeInstance , initStorage } from "../../store/storage.js" ;
18- import { Bump } from "../../store/models/Bump.js" ;
19- import { clearBumpsCache } from "../../store/models/bumps.js" ;
16+ import {
17+ handleBumpStreak ,
18+ setLastBumpNotificationTime ,
19+ } from "./bump.listener.js" ;
2020
2121beforeAll ( async ( ) => {
2222 await initStorage ( ) ;
@@ -107,9 +107,7 @@ test("simple bump with big streak", async () => {
107107 for ( let i = 0 ; i < 9 ; i ++ ) {
108108 await Bump . create ( {
109109 userId : BigInt ( fakeUser . id ) ,
110- timestamp : new Date (
111- new Date ( ) . getTime ( ) - 1000 * 60 * 60 * 24 * ( 10 - i ) ,
112- ) ,
110+ timestamp : new Date ( Date . now ( ) - 1000 * 60 * 60 * 24 * ( 10 - i ) ) ,
113111 messageId : BigInt ( 10 + i ) ,
114112 } ) ;
115113 }
@@ -136,7 +134,7 @@ test("simple bump with big streak", async () => {
136134
137135test ( "speedy bump " , async ( ) => {
138136 const { ddUser, fakeUser, mockReact, mockChannel } = await setupMocks ( ) ;
139- setLastBumpNotificationTime ( new Date ( new Date ( ) . getTime ( ) - 1000 ) ) ;
137+ setLastBumpNotificationTime ( new Date ( Date . now ( ) - 1000 ) ) ;
140138 await handleBumpStreak (
141139 ddUser ,
142140 { user : fakeUser } as unknown as MessageInteraction ,
@@ -157,9 +155,7 @@ test("End other user's streak", async () => {
157155 for ( let i = 0 ; i < 5 ; i ++ ) {
158156 await Bump . create ( {
159157 userId : BigInt ( fakeUser . id ) ,
160- timestamp : new Date (
161- new Date ( ) . getTime ( ) - 1000 * 60 * 60 * 24 * ( 10 - i ) ,
162- ) ,
158+ timestamp : new Date ( Date . now ( ) - 1000 * 60 * 60 * 24 * ( 10 - i ) ) ,
163159 messageId : BigInt ( 10 + i ) ,
164160 } ) ;
165161 }
0 commit comments