@@ -4,10 +4,33 @@ const Server = require('../../..').Server,
4
4
mock = require ( '../../mock' ) ,
5
5
expect = require ( 'chai' ) . expect ,
6
6
ServerSessionPool = require ( '../../../lib/sessions' ) . ServerSessionPool ,
7
- ServerSession = require ( '../../../lib/sessions' ) . ServerSession ;
7
+ ServerSession = require ( '../../../lib/sessions' ) . ServerSession ,
8
+ ClientSession = require ( '../../../lib/sessions' ) . ClientSession ,
9
+ genClusterTime = require ( './common' ) . genClusterTime ;
8
10
9
11
let test = { } ;
10
12
describe ( 'Sessions' , function ( ) {
13
+ describe ( 'ClientSession' , function ( ) {
14
+ it ( 'should default to `null` for `clusterTime`' , {
15
+ metadata : { requires : { topology : 'single' } } ,
16
+ test : function ( ) {
17
+ const client = new Server ( ) ;
18
+ const session = new ClientSession ( client ) ;
19
+ expect ( session . clusterTime ) . to . not . exist ;
20
+ }
21
+ } ) ;
22
+
23
+ it ( 'should set the internal clusterTime to `initialClusterTime` if provided' , {
24
+ metadata : { requires : { topology : 'single' } } ,
25
+ test : function ( ) {
26
+ const clusterTime = genClusterTime ( Date . now ( ) ) ;
27
+ const client = new Server ( ) ;
28
+ const session = new ClientSession ( client , { initialClusterTime : clusterTime } ) ;
29
+ expect ( session . clusterTime ) . to . eql ( clusterTime ) ;
30
+ }
31
+ } ) ;
32
+ } ) ;
33
+
11
34
describe ( 'ServerSessionPool' , function ( ) {
12
35
afterEach ( ( ) => {
13
36
test . client . destroy ( ) ;
@@ -41,7 +64,6 @@ describe('Sessions', function() {
41
64
42
65
it ( 'should create a new session if the pool is empty' , {
43
66
metadata : { requires : { topology : 'single' } } ,
44
-
45
67
test : function ( done ) {
46
68
const pool = new ServerSessionPool ( test . client ) ;
47
69
expect ( pool . sessions ) . to . have . length ( 0 ) ;
0 commit comments