BVB Source Codes

parse-server Show PostgresConfigParser.spec.js Source code

Return Download parse-server: download PostgresConfigParser.spec.js Source code - Download parse-server Source code - Type:.js
  1. const parser = require('../src/Adapters/Storage/Postgres/PostgresConfigParser');
  2.  
  3. const queryParamTests = {
  4.   'a=1&b=2': { a: '1', b: '2' },
  5.   'a=abcd%20efgh&b=abcd%3Defgh': { a: 'abcd efgh', b: 'abcd=efgh' },
  6.   'a=1&b&c=true': { a: '1', b: '', c: 'true' }
  7. }
  8.  
  9. describe('PostgresConfigParser.parseQueryParams', () => {
  10.   it('creates a map from a query string', () => {
  11.  
  12.     for (const key in queryParamTests) {
  13.       const result = parser.parseQueryParams(key);
  14.  
  15.       const testObj = queryParamTests[key];
  16.  
  17.       expect(Object.keys(result).length)
  18.         .toEqual(Object.keys(testObj).length);
  19.  
  20.       for (const k in result) {
  21.         expect(result[k]).toEqual(testObj[k]);
  22.       }
  23.     }
  24.  
  25.   })
  26. });
  27.  
  28. const baseURI = 'postgres://username:password@localhost:5432/db-name'
  29.  
  30. const dbOptionsTest = {};
  31. dbOptionsTest[`${baseURI}?ssl=true&binary=true&application_name=app_name&fallback_application_name=f_app_name&poolSize=10`] = {
  32.   ssl: true,
  33.   binary: true,
  34.   application_name: 'app_name',
  35.   fallback_application_name: 'f_app_name',
  36.   poolSize: 10
  37. };
  38. dbOptionsTest[`${baseURI}?ssl=&binary=aa`] = {
  39.   ssl: false,
  40.   binary: false
  41. }
  42.  
  43. describe('PostgresConfigParser.getDatabaseOptionsFromURI', () => {
  44.   it('creates a db options map from a query string', () => {
  45.  
  46.     for (const key in dbOptionsTest) {
  47.       const result = parser.getDatabaseOptionsFromURI(key);
  48.  
  49.       const testObj = dbOptionsTest[key];
  50.  
  51.       for (const k in testObj) {
  52.         expect(result[k]).toEqual(testObj[k]);
  53.       }
  54.     }
  55.  
  56.   });
  57.  
  58.   it('sets the poolSize to 10 if the it is not a number', () => {
  59.  
  60.     const result = parser.getDatabaseOptionsFromURI(`${baseURI}?poolSize=sdf`);
  61.  
  62.     expect(result.poolSize).toEqual(10);
  63.  
  64.   });
  65. });
  66.  
downloadPostgresConfigParser.spec.js Source code - Download parse-server Source code
Related Source Codes/Software:
react-boilerplate - 2017-06-07
webtorrent - Streaming torrent client for the web ... 2017-06-06
machine-learning-for-software-engineers - A complete daily plan for studying to become a mac... 2017-06-06
upterm - A terminal emulator for the 21st century. 2017-06-06
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
storybook - 2017-06-07
prettier - Prettier is an opinionated JavaScript formatter. ... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top