Use Prettier JS (#5017)

* Adds prettier

* Run lint before tests
This commit is contained in:
Florent Vilmart
2018-09-01 13:58:06 -04:00
committed by GitHub
parent 189cd259ee
commit d83a0b6808
240 changed files with 41098 additions and 29020 deletions

View File

@@ -3,47 +3,45 @@ const parser = require('../lib/Adapters/Storage/Postgres/PostgresConfigParser');
const queryParamTests = {
'a=1&b=2': { a: '1', b: '2' },
'a=abcd%20efgh&b=abcd%3Defgh': { a: 'abcd efgh', b: 'abcd=efgh' },
'a=1&b&c=true': { a: '1', b: '', c: 'true' }
}
'a=1&b&c=true': { a: '1', b: '', c: 'true' },
};
describe('PostgresConfigParser.parseQueryParams', () => {
it('creates a map from a query string', () => {
for (const key in queryParamTests) {
const result = parser.parseQueryParams(key);
const testObj = queryParamTests[key];
expect(Object.keys(result).length)
.toEqual(Object.keys(testObj).length);
expect(Object.keys(result).length).toEqual(Object.keys(testObj).length);
for (const k in result) {
expect(result[k]).toEqual(testObj[k]);
}
}
})
});
});
const baseURI = 'postgres://username:password@localhost:5432/db-name'
const baseURI = 'postgres://username:password@localhost:5432/db-name';
const dbOptionsTest = {};
dbOptionsTest[`${baseURI}?ssl=true&binary=true&application_name=app_name&fallback_application_name=f_app_name&poolSize=10`] = {
dbOptionsTest[
`${baseURI}?ssl=true&binary=true&application_name=app_name&fallback_application_name=f_app_name&poolSize=10`
] = {
ssl: true,
binary: true,
application_name: 'app_name',
fallback_application_name: 'f_app_name',
poolSize: 10
poolSize: 10,
};
dbOptionsTest[`${baseURI}?ssl=&binary=aa`] = {
ssl: false,
binary: false
}
binary: false,
};
describe('PostgresConfigParser.getDatabaseOptionsFromURI', () => {
it('creates a db options map from a query string', () => {
for (const key in dbOptionsTest) {
for (const key in dbOptionsTest) {
const result = parser.getDatabaseOptionsFromURI(key);
const testObj = dbOptionsTest[key];
@@ -52,14 +50,11 @@ describe('PostgresConfigParser.getDatabaseOptionsFromURI', () => {
expect(result[k]).toEqual(testObj[k]);
}
}
});
it('sets the poolSize to 10 if the it is not a number', () => {
const result = parser.getDatabaseOptionsFromURI(`${baseURI}?poolSize=sdf`);
expect(result.poolSize).toEqual(10);
});
});