forked from antongolub/reqresnext
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: utility to lowercase object properties
refs antongolub#33 - Adds utility that will help mimicing lowercasing of headers like it's done in express' Request object - Code heavily inspired by https://github.com/howardabrams/node-mocks-http/blob/a0ad193459c102069a9b7de386f16ebf59cab6e0/lib/utils.js#L3-L9
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { convertKeysToLowerCase } from '../../main/js/util' | ||
|
||
describe('util', () => { | ||
describe('convertKeysToLowerCase', () => { | ||
it('converts object keys to lower case keys', () => { | ||
const map = { | ||
prop: 'value', | ||
standard_Notation: 42, | ||
'BaZ-Header': 'qux' | ||
} | ||
|
||
const lowerCasedMap = convertKeysToLowerCase(map) | ||
|
||
expect(map.standard_Notation).toEqual(42, 'original map is not modified') | ||
|
||
expect(lowerCasedMap.prop).toEqual('value') | ||
expect(lowerCasedMap.standard_notation).toEqual(42) | ||
expect(lowerCasedMap['baz-header']).toEqual('qux') | ||
}) | ||
}) | ||
}) |