|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const { expect } = require('chai'); |
| 4 | +const { ListCollectionsOperation } = require('../../../src/operations/list_collections'); |
| 5 | + |
| 6 | +describe('ListCollectionsOperation', function () { |
| 7 | + const db = 'test'; |
| 8 | + |
| 9 | + describe('#constructor', function () { |
| 10 | + context('when nameOnly is provided', function () { |
| 11 | + context('when nameOnly is true', function () { |
| 12 | + const operation = new ListCollectionsOperation(db, {}, { nameOnly: true, dbName: db }); |
| 13 | + |
| 14 | + it('sets nameOnly to true', function () { |
| 15 | + expect(operation.nameOnly).to.be.true; |
| 16 | + }); |
| 17 | + }); |
| 18 | + |
| 19 | + context('when nameOnly is false', function () { |
| 20 | + const operation = new ListCollectionsOperation(db, {}, { nameOnly: false, dbName: db }); |
| 21 | + |
| 22 | + it('sets nameOnly to false', function () { |
| 23 | + expect(operation.nameOnly).to.be.false; |
| 24 | + }); |
| 25 | + }); |
| 26 | + }); |
| 27 | + |
| 28 | + context('when nameOnly is not provided', function () { |
| 29 | + const operation = new ListCollectionsOperation(db, {}, { dbName: db }); |
| 30 | + |
| 31 | + it('sets nameOnly to false', function () { |
| 32 | + expect(operation.nameOnly).to.be.false; |
| 33 | + }); |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + describe('#generateCommand', function () { |
| 38 | + context('when nameOnly is provided', function () { |
| 39 | + context('when nameOnly is true', function () { |
| 40 | + const operation = new ListCollectionsOperation(db, {}, { nameOnly: true, dbName: db }); |
| 41 | + |
| 42 | + it('sets nameOnly to true', function () { |
| 43 | + expect(operation.generateCommand()).to.deep.equal({ |
| 44 | + listCollections: 1, |
| 45 | + cursor: {}, |
| 46 | + filter: {}, |
| 47 | + nameOnly: true |
| 48 | + }); |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + context('when nameOnly is false', function () { |
| 53 | + const operation = new ListCollectionsOperation(db, {}, { nameOnly: false, dbName: db }); |
| 54 | + |
| 55 | + it('sets nameOnly to false', function () { |
| 56 | + expect(operation.generateCommand()).to.deep.equal({ |
| 57 | + listCollections: 1, |
| 58 | + cursor: {}, |
| 59 | + filter: {}, |
| 60 | + nameOnly: false |
| 61 | + }); |
| 62 | + }); |
| 63 | + }); |
| 64 | + }); |
| 65 | + |
| 66 | + context('when nameOnly is not provided', function () { |
| 67 | + const operation = new ListCollectionsOperation(db, {}, { dbName: db }); |
| 68 | + |
| 69 | + it('sets nameOnly to false', function () { |
| 70 | + expect(operation.generateCommand()).to.deep.equal({ |
| 71 | + listCollections: 1, |
| 72 | + cursor: {}, |
| 73 | + filter: {}, |
| 74 | + nameOnly: false |
| 75 | + }); |
| 76 | + }); |
| 77 | + }); |
| 78 | + }); |
| 79 | +}); |
0 commit comments