Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Commit

Permalink
[#568] Rename variables in pgTypes patch to be more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
georgiana-b committed Dec 12, 2016
1 parent ce60542 commit 9a4fab7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions config/pg_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function parseDateArray(value) {
return null;
}

const p = pgTypes.arrayParser.create(value, (entry) => {
const parser = pgTypes.arrayParser.create(value, (entry) => {
let parsedEntry = entry;
if (String(entry).toLowerCase() !== String(null)) {
parsedEntry = parseDate(entry);
Expand All @@ -29,7 +29,7 @@ function parseDateArray(value) {
return parsedEntry;
});

return p.parse();
return parser.parse();
}

pgTypes.setTypeParser(DATE_OID, parseDate);
Expand Down
16 changes: 8 additions & 8 deletions test/config/pg_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ describe('parseDateArray', () => {

it('parses array correctly', () => {
let testDate = '2014-01-12';
let testArray = `{${testDate}}`;
let testPgArray = `{${testDate}}`;
let expectedDate = new Date(testDate).toISOString();
let resultedArray = parseDateArray(testArray);
let resultedArray = parseDateArray(testPgArray);
resultedArray.map((date) => date.toISOString()).should.deepEqual([
expectedDate,
]);
});

it('returns null when value is null', () => {
let testArray = null;
should(parseDateArray(testArray)).equal(null);
let testPgArray = null;
should(parseDateArray(testPgArray)).equal(null);
});

it('returns empty array when there are no values', () => {
let testArray = `{}`;
parseDateArray(testArray).should.be.empty();
let testPgArray = `{}`;
parseDateArray(testPgArray).should.be.empty();
});

it('returns null for the null values', () => {
let testArray = `{null}`;
parseDateArray(testArray).should.deepEqual([
let testPgArray = `{null}`;
parseDateArray(testPgArray).should.deepEqual([
null,
]);
});
Expand Down

0 comments on commit 9a4fab7

Please sign in to comment.