We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9b64cab commit 5d0f7d7Copy full SHA for 5d0f7d7
1 file changed
lib/mongodb.test.ts
@@ -58,4 +58,18 @@ describe('dbConnect', () => {
58
// The promise should be cleared so it can try again
59
expect(global.mongoose.promise).toBeNull();
60
});
61
+
62
+ it('calls mongoose.connect with the exact URI set in MONGODB_URI', async () => {
63
+ const specificUri = 'mongodb://specific-host:27017/mydb';
64
+ process.env.MONGODB_URI = specificUri;
65
66
+ const mockMongoose = { connection: 'mock' };
67
+ vi.mocked(mongoose.connect).mockResolvedValue(mockMongoose as unknown as typeof mongoose);
68
69
+ await dbConnect();
70
71
+ expect(mongoose.connect).toHaveBeenCalledWith(specificUri, {
72
+ bufferCommands: false,
73
+ });
74
75
0 commit comments