@@ -110,46 +110,86 @@ describe('Explainable', function () {
110
110
} ) ;
111
111
112
112
describe ( 'find' , function ( ) {
113
- let cursorStub ;
114
- let explainResult ;
115
- beforeEach ( async function ( ) {
116
- explainResult = { ok : 1 } ;
113
+ context ( 'without options' , function ( ) {
114
+ let cursorStub ;
115
+ let explainResult ;
117
116
118
- const cursorSpy = {
119
- explain : sinon . spy ( ( ) => explainResult ) ,
120
- } as unknown ;
121
- collection . find = sinon . spy ( ( ) => Promise . resolve ( cursorSpy as Cursor ) ) ;
117
+ beforeEach ( async function ( ) {
118
+ explainResult = { ok : 1 } ;
122
119
123
- cursorStub = await explainable . find ( { query : 1 } , { projection : 1 } ) ;
124
- } ) ;
120
+ const cursorSpy = {
121
+ explain : sinon . spy ( ( ) => explainResult ) ,
122
+ } as unknown ;
123
+ collection . find = sinon . spy ( ( ) =>
124
+ Promise . resolve ( cursorSpy as Cursor )
125
+ ) ;
125
126
126
- it ( 'calls collection.find with arguments' , function ( ) {
127
- expect ( collection . find ) . to . have . been . calledOnceWithExactly (
128
- { query : 1 } ,
129
- { projection : 1 }
130
- ) ;
131
- } ) ;
127
+ cursorStub = await explainable . find ( { query : 1 } , { projection : 1 } ) ;
128
+ } ) ;
129
+
130
+ it ( 'calls collection.find with arguments' , function ( ) {
131
+ expect ( collection . find ) . to . have . been . calledOnceWithExactly (
132
+ { query : 1 } ,
133
+ { projection : 1 } ,
134
+ { }
135
+ ) ;
136
+ } ) ;
137
+
138
+ it ( 'returns an cursor that has toShellResult when evaluated' , async function ( ) {
139
+ expect ( ( await toShellResult ( cursorStub ) ) . type ) . to . equal (
140
+ 'ExplainableCursor'
141
+ ) ;
142
+ } ) ;
143
+
144
+ context (
145
+ 'when calling toShellResult().printable on the result' ,
146
+ function ( ) {
147
+ it ( 'calls explain with verbosity' , function ( ) {
148
+ expect ( cursorStub . _verbosity ) . to . equal ( 'queryPlanner' ) ;
149
+ } ) ;
132
150
133
- it ( 'returns an cursor that has toShellResult when evaluated' , async function ( ) {
134
- expect ( ( await toShellResult ( cursorStub ) ) . type ) . to . equal (
135
- 'ExplainableCursor'
151
+ it ( 'returns the explain result' , async function ( ) {
152
+ expect ( ( await toShellResult ( cursorStub ) ) . printable ) . to . equal (
153
+ explainResult
154
+ ) ;
155
+ } ) ;
156
+ }
136
157
) ;
137
158
} ) ;
138
159
139
- context (
140
- 'when calling toShellResult().printable on the result' ,
141
- function ( ) {
142
- it ( 'calls explain with verbosity' , function ( ) {
143
- expect ( cursorStub . _verbosity ) . to . equal ( 'queryPlanner' ) ;
144
- } ) ;
160
+ context ( 'with options' , function ( ) {
161
+ let cursorStub ;
162
+ let explainResult ;
163
+
164
+ beforeEach ( async function ( ) {
165
+ explainResult = { ok : 1 } ;
166
+
167
+ const cursorSpy = {
168
+ explain : sinon . spy ( ( ) => explainResult ) ,
169
+ } as unknown ;
170
+ collection . find = sinon . spy ( ( ) =>
171
+ Promise . resolve ( cursorSpy as Cursor )
172
+ ) ;
145
173
146
- it ( 'returns the explain result' , async function ( ) {
147
- expect ( ( await toShellResult ( cursorStub ) ) . printable ) . to . equal (
148
- explainResult
149
- ) ;
174
+ cursorStub = await explainable . find ( { } , undefined , {
175
+ collation : { locale : 'simple' } ,
150
176
} ) ;
151
- }
152
- ) ;
177
+ } ) ;
178
+
179
+ it ( 'calls collection.find with arguments' , function ( ) {
180
+ expect ( collection . find ) . to . have . been . calledOnceWithExactly (
181
+ { } ,
182
+ undefined ,
183
+ { collation : { locale : 'simple' } }
184
+ ) ;
185
+ } ) ;
186
+
187
+ it ( 'returns an cursor that has toShellResult when evaluated' , async function ( ) {
188
+ expect ( ( await toShellResult ( cursorStub ) ) . type ) . to . equal (
189
+ 'ExplainableCursor'
190
+ ) ;
191
+ } ) ;
192
+ } ) ;
153
193
} ) ;
154
194
155
195
describe ( 'aggregate' , function ( ) {
0 commit comments