| 39 | |
| 40 | describe('class GridFSBucket', () => { |
| 41 | const assertIndexesExist = () => { |
| 42 | expect(bucket.s).to.have.property('checkedIndexes', true); |
| 43 | |
| 44 | const listIndexes = commandStartedEvents.filter(e => e.commandName === 'listIndexes'); |
| 45 | expect(listIndexes).to.have.lengthOf(2); |
| 46 | |
| 47 | const createIndexes = commandStartedEvents.filter(e => e.commandName === 'createIndexes'); |
| 48 | expect(createIndexes).to.have.lengthOf(2); |
| 49 | expect(createIndexes[0]).to.have.deep.nested.property('command.createIndexes', 'fs.files'); |
| 50 | expect(createIndexes[0]).to.have.deep.nested.property( |
| 51 | 'command.indexes[0].key', |
| 52 | new Map([ |
| 53 | ['filename', 1], |
| 54 | ['uploadDate', 1] |
| 55 | ]) |
| 56 | ); |
| 57 | expect(createIndexes[1]).to.have.deep.nested.property('command.createIndexes', 'fs.chunks'); |
| 58 | expect(createIndexes[1]).to.have.deep.nested.property( |
| 59 | 'command.indexes[0].key', |
| 60 | new Map([ |
| 61 | ['files_id', 1], |
| 62 | ['n', 1] |
| 63 | ]) |
| 64 | ); |
| 65 | }; |
| 66 | |
| 67 | it('ensures chunks and files collection have required indexes when namespace does not exist', async () => { |
| 68 | // Ensure the namespace does not exist; beforeEach should drop the Db, keeping this true |