-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(NODE-3150): allow retrieving PCRE-style RegExp
- Loading branch information
Showing
11 changed files
with
78 additions
and
12 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
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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
const { expect } = require('chai'); | ||
const { BSONRegExp } = require('../../src/index'); | ||
|
||
describe('BSONRegExp', () => { | ||
describe('bsonRegExp option', () => { | ||
// define client and option for tests to use | ||
let client; | ||
const option = { bsonRegExp: true }; | ||
for (const passOptionTo of ['client', 'db', 'collection', 'operation']) { | ||
it(`should respond with BSONRegExp class with option passed to ${passOptionTo}`, async function () { | ||
try { | ||
client = this.configuration.newClient(passOptionTo === 'client' ? option : undefined); | ||
await client.connect(); | ||
|
||
const db = client.db('bson_regex_db', passOptionTo === 'db' ? option : undefined); | ||
const collection = db.collection( | ||
'bson_regex_coll', | ||
passOptionTo === 'collection' ? option : undefined | ||
); | ||
|
||
await collection.insertOne({ regex: new BSONRegExp('abc', 'imx') }); | ||
const res = await collection.findOne( | ||
{ regex: new BSONRegExp('abc', 'imx') }, | ||
passOptionTo === 'operation' ? option : undefined | ||
); | ||
|
||
expect(res).has.property('regex').that.is.instanceOf(BSONRegExp); | ||
} finally { | ||
await client.close(); | ||
} | ||
}); | ||
} | ||
}); | ||
}); |