-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add client option when create store
- Loading branch information
Showing
5 changed files
with
40 additions
and
6 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
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,6 +1,8 @@ | ||
import test from 'ava' | ||
import { SessionData } from 'express-session' | ||
import { MongoClient } from 'mongodb' | ||
|
||
import MongoStore from './MongoStore' | ||
import { | ||
createStoreHelper, | ||
makeData, | ||
|
@@ -23,6 +25,30 @@ test.afterEach.always(async () => { | |
await storePromise.close() | ||
}) | ||
|
||
test.serial('create store w/o provide required options', (t) => { | ||
t.throws(() => MongoStore.create({}), { | ||
message: /Cannot init client/, | ||
}) | ||
}) | ||
|
||
test.serial('create store with clientPromise', (t) => { | ||
const clientP = MongoClient.connect('mongodb://root:[email protected]:27017') | ||
const store = MongoStore.create({ clientPromise: clientP }) | ||
t.not(store, null) | ||
t.not(store, undefined) | ||
store.close() | ||
}) | ||
|
||
test.serial('create store with client', async (t) => { | ||
const client = await MongoClient.connect( | ||
'mongodb://root:[email protected]:27017' | ||
) | ||
const store = MongoStore.create({ client: client }) | ||
t.not(store, null) | ||
t.not(store, undefined) | ||
store.close() | ||
}) | ||
|
||
test.serial('length should be 0', async (t) => { | ||
;({ store, storePromise } = createStoreHelper()) | ||
const length = await storePromise.length() | ||
|
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