Skip to content

Commit

Permalink
feat: fix type and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirke committed Oct 21, 2024
1 parent 3fd7513 commit 3417954
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { caching } from 'cache-manager'
import { MongoClient } from 'mongodb'

import { mongoDbStore, MongoCache } from './node-cache-manager-mongodb'

Expand Down Expand Up @@ -325,3 +326,15 @@ describe('databaseName', () => {
await baseCache.reset()
})
})

describe('reusing Mongo client', () => {
it('should reuse the client', async () => {
const mongoClient = new MongoClient('mongodb://localhost:27017')
const cache = await caching(mongoDbStore, {
client: mongoClient,
})

await cache.set('foo', 'bar')
expect(cache.store.client).toEqual(mongoClient)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Args = {
mongoConfig?: MongoClientOptions
collectionName?: string
databaseName?: string
client?: MongoClient
} & Config


Expand Down

0 comments on commit 3417954

Please sign in to comment.