Browse Source

chore: improve tests of "isObjectId"

e22m4u 2 years ago
parent
commit
d27915ba48
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/utils/is-object-id.spec.js

+ 6 - 4
src/utils/is-object-id.spec.js

@@ -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;
   });
 });