Guest User

Untitled

a guest
Nov 22nd, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // remove sensitive data
  2. const hashData = (xs, y) => R.mapObjIndexed((x, key) => key.includes(y) ? '******' : x, xs);
  3.  
  4. // tests
  5. describe('hashData', () => {
  6. it('should hash out sensitive information as expected', async () => {
  7. // given ... object that includes sensitive information
  8. const sensitiveObject = {
  9. username: 'john',
  10. password: 'my-super-secret-password',
  11. };
  12.  
  13. // when ... we run the hashData function providing which data to hash
  14. const result = SUT.hashData(sensitiveObject, ['password']);
  15.  
  16. // then ... returned data should be as expected
  17. const expectedResult = {
  18. username: 'john',
  19. password: '******',
  20. };
  21.  
  22. assert.deepEqual(result, expectedResult);
  23. });
  24. });
Add Comment
Please, Sign In to add comment