11'use strict' ;
22
33const { expect } = require ( 'chai' ) ;
4- const { ListCollectionsOperation } = require ( '../../mongodb' ) ;
4+ const { ListCollectionsOperation, StreamDescription } = require ( '../../mongodb' ) ;
55
66describe ( 'ListCollectionsOperation' , function ( ) {
77 const db = 'test' ;
@@ -65,6 +65,8 @@ describe('ListCollectionsOperation', function () {
6565 } ) ;
6666
6767 describe ( '#generateCommand' , function ( ) {
68+ const description = new StreamDescription ( ) ;
69+
6870 context ( 'when comment is provided' , function ( ) {
6971 context ( 'when the wireVersion < 9' , function ( ) {
7072 it ( 'does not set a comment on the command' , function ( ) {
@@ -73,7 +75,10 @@ describe('ListCollectionsOperation', function () {
7375 { } ,
7476 { dbName : db , comment : 'test comment' }
7577 ) ;
76- const command = operation . generateCommand ( 8 ) ;
78+ description . maxWireVersion = 8 ;
79+ const command = operation . buildCommandDocument ( {
80+ description
81+ } ) ;
7782 expect ( command ) . not . to . haveOwnProperty ( 'comment' ) ;
7883 } ) ;
7984 } ) ;
@@ -85,7 +90,10 @@ describe('ListCollectionsOperation', function () {
8590 { } ,
8691 { dbName : db , comment : 'test comment' }
8792 ) ;
88- const command = operation . generateCommand ( 9 ) ;
93+ description . maxWireVersion = 9 ;
94+ const command = operation . buildCommandDocument ( {
95+ description
96+ } ) ;
8997 expect ( command ) . to . have . property ( 'comment' ) . that . equals ( 'test comment' ) ;
9098 } ) ;
9199 } ) ;
@@ -95,7 +103,11 @@ describe('ListCollectionsOperation', function () {
95103 const operation = new ListCollectionsOperation ( db , { } , { nameOnly : true , dbName : db } ) ;
96104
97105 it ( 'sets nameOnly to true' , function ( ) {
98- expect ( operation . generateCommand ( 8 ) ) . to . deep . equal ( {
106+ description . maxWireVersion = 8 ;
107+ const command = operation . buildCommandDocument ( {
108+ description
109+ } ) ;
110+ expect ( command ) . to . deep . equal ( {
99111 listCollections : 1 ,
100112 cursor : { } ,
101113 filter : { } ,
@@ -109,7 +121,11 @@ describe('ListCollectionsOperation', function () {
109121 const operation = new ListCollectionsOperation ( db , { } , { nameOnly : false , dbName : db } ) ;
110122
111123 it ( 'sets nameOnly to false' , function ( ) {
112- expect ( operation . generateCommand ( 8 ) ) . to . deep . equal ( {
124+ description . maxWireVersion = 8 ;
125+ const command = operation . buildCommandDocument ( {
126+ description
127+ } ) ;
128+ expect ( command ) . to . deep . equal ( {
113129 listCollections : 1 ,
114130 cursor : { } ,
115131 filter : { } ,
@@ -129,7 +145,11 @@ describe('ListCollectionsOperation', function () {
129145 ) ;
130146
131147 it ( 'sets authorizedCollections to true' , function ( ) {
132- expect ( operation . generateCommand ( 8 ) ) . to . deep . equal ( {
148+ description . maxWireVersion = 8 ;
149+ const command = operation . buildCommandDocument ( {
150+ description
151+ } ) ;
152+ expect ( command ) . to . deep . equal ( {
133153 listCollections : 1 ,
134154 cursor : { } ,
135155 filter : { } ,
@@ -147,7 +167,11 @@ describe('ListCollectionsOperation', function () {
147167 ) ;
148168
149169 it ( 'sets authorizedCollections to false' , function ( ) {
150- expect ( operation . generateCommand ( 8 ) ) . to . deep . equal ( {
170+ description . maxWireVersion = 8 ;
171+ const command = operation . buildCommandDocument ( {
172+ description
173+ } ) ;
174+ expect ( command ) . to . deep . equal ( {
151175 listCollections : 1 ,
152176 cursor : { } ,
153177 filter : { } ,
@@ -162,7 +186,11 @@ describe('ListCollectionsOperation', function () {
162186 const operation = new ListCollectionsOperation ( db , { } , { dbName : db } ) ;
163187
164188 it ( 'sets nameOnly and authorizedCollections properties to false' , function ( ) {
165- expect ( operation . generateCommand ( 8 ) ) . to . deep . equal ( {
189+ description . maxWireVersion = 8 ;
190+ const command = operation . buildCommandDocument ( {
191+ description
192+ } ) ;
193+ expect ( command ) . to . deep . equal ( {
166194 listCollections : 1 ,
167195 cursor : { } ,
168196 filter : { } ,
0 commit comments