Skip to content

Commit

Permalink
Add unit test for connection options
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuanyu Wang committed Nov 16, 2020
1 parent 2a60634 commit 42680c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/database.js
Expand Up @@ -59,6 +59,23 @@ describe('database', function() {
await dbShort.close();
});

it('should accept connection with options', async () => {
// auth should fail with invalid 'authSource', to make sure options take effect
const cannotConnect = mongoist('localhost:27017/test', { 'authSource': 'dummy' });
let errorEvent = null;
cannotConnect.on('error', (error) => {
errorEvent = error;
});

try {
await cannotConnect.test.find();
await cannotConnect.close();
} catch (e) {
expect(errorEvent).to.exist;
return;
}
});

it('should create a collection', async() => {
const collection = await db.createCollection('test123');

Expand Down

0 comments on commit 42680c0

Please sign in to comment.