|
| 1 | +import { once } from 'node:events'; |
| 2 | +import * as process from 'node:process'; |
| 3 | + |
1 | 4 | import { expect } from 'chai';
|
2 | 5 | import * as dns from 'dns';
|
3 | 6 | import * as sinon from 'sinon';
|
@@ -761,4 +764,40 @@ describe('Connection String', function () {
|
761 | 764 | expect(() => new MongoClient('mango://localhost:23')).to.throw(/Invalid scheme/i);
|
762 | 765 | expect(() => new MongoClient('mango+srv://localhost:23')).to.throw(/Invalid scheme/i);
|
763 | 766 | });
|
| 767 | + |
| 768 | + describe('when deprecated options are used', () => { |
| 769 | + it('useNewUrlParser emits a warning', async () => { |
| 770 | + let willBeWarning = once(process, 'warning'); |
| 771 | + parseOptions('mongodb://host?useNewUrlParser=true'); |
| 772 | + let [warning] = await willBeWarning; |
| 773 | + expect(warning) |
| 774 | + .to.have.property('message') |
| 775 | + .that.matches(/useNewUrlParser has no effect/); |
| 776 | + |
| 777 | + willBeWarning = once(process, 'warning'); |
| 778 | + //@ts-expect-error: using unsupported option on purpose |
| 779 | + parseOptions('mongodb://host', { useNewUrlParser: true }); |
| 780 | + [warning] = await willBeWarning; |
| 781 | + expect(warning) |
| 782 | + .to.have.property('message') |
| 783 | + .that.matches(/useNewUrlParser has no effect/); |
| 784 | + }); |
| 785 | + |
| 786 | + it('useUnifiedTopology emits a warning', async () => { |
| 787 | + let willBeWarning = once(process, 'warning'); |
| 788 | + parseOptions('mongodb://host?useUnifiedTopology=true'); |
| 789 | + let [warning] = await willBeWarning; |
| 790 | + expect(warning) |
| 791 | + .to.have.property('message') |
| 792 | + .that.matches(/useUnifiedTopology has no effect/); |
| 793 | + |
| 794 | + willBeWarning = once(process, 'warning'); |
| 795 | + //@ts-expect-error: using unsupported option on purpose |
| 796 | + parseOptions('mongodb://host', { useUnifiedTopology: true }); |
| 797 | + [warning] = await willBeWarning; |
| 798 | + expect(warning) |
| 799 | + .to.have.property('message') |
| 800 | + .that.matches(/useUnifiedTopology has no effect/); |
| 801 | + }); |
| 802 | + }); |
764 | 803 | });
|
0 commit comments