PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/spec/MongoStorageAdapter.spec.js

https://gitlab.com/fabiorf/parse-server
JavaScript | 37 lines | 32 code | 4 blank | 1 comment | 0 complexity | 725df2dd8f8f75b83b902ad4a8348754 MD5 | raw file
  1. 'use strict';
  2. const MongoStorageAdapter = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter');
  3. const MongoClient = require('mongodb').MongoClient;
  4. describe('MongoStorageAdapter', () => {
  5. it('auto-escapes symbols in auth information', () => {
  6. spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
  7. new MongoStorageAdapter('mongodb://user!with@+ symbols:password!with@+ symbols@localhost:1234/parse', {})
  8. .connect();
  9. expect(MongoClient.connect).toHaveBeenCalledWith(
  10. 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse',
  11. jasmine.any(Object)
  12. );
  13. });
  14. it("doesn't double escape already URI-encoded information", () => {
  15. spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
  16. new MongoStorageAdapter('mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse', {})
  17. .connect();
  18. expect(MongoClient.connect).toHaveBeenCalledWith(
  19. 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse',
  20. jasmine.any(Object)
  21. );
  22. });
  23. // https://github.com/ParsePlatform/parse-server/pull/148#issuecomment-180407057
  24. it('preserves replica sets', () => {
  25. spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
  26. new MongoStorageAdapter('mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415', {})
  27. .connect();
  28. expect(MongoClient.connect).toHaveBeenCalledWith(
  29. 'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415',
  30. jasmine.any(Object)
  31. );
  32. });
  33. });