|
|
@@ -1,9 +1,14 @@
|
|
|
import {expect} from 'chai';
|
|
|
-import {isObjectId} from './is-object-id.js';
|
|
|
import {ObjectId} from 'mongodb';
|
|
|
+import {isObjectId} from './is-object-id.js';
|
|
|
|
|
|
describe('isObjectId', function () {
|
|
|
it('returns true for a valid ObjectId string or an instance', function () {
|
|
|
+ expect(isObjectId(new ObjectId())).to.be.true;
|
|
|
+ expect(isObjectId(String(new ObjectId()))).to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('returns false for invalid values', function () {
|
|
|
expect(isObjectId('')).to.be.false;
|
|
|
expect(isObjectId('123')).to.be.false;
|
|
|
expect(isObjectId(0)).to.be.false;
|
|
|
@@ -17,8 +22,5 @@ describe('isObjectId', function () {
|
|
|
expect(isObjectId(new Date())).to.be.false;
|
|
|
expect(isObjectId(null)).to.be.false;
|
|
|
expect(isObjectId(undefined)).to.be.false;
|
|
|
- //
|
|
|
- expect(isObjectId(new ObjectId())).to.be.true;
|
|
|
- expect(isObjectId(String(new ObjectId()))).to.be.true;
|
|
|
});
|
|
|
});
|