Skip to content

Commit

Permalink
minor fix for post route test to use hash function
Browse files Browse the repository at this point in the history
  • Loading branch information
marythedev committed Oct 12, 2023
1 parent 2865677 commit 58c3747
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
*
* 6Xoj0UXOW3FNirlSYranli5gY6dDq60hs24EIAcHAEc=
*
* You can either use the whole thing, or truncate to only use the first 8
* Use .slice(0, 8) if you want reduce the size and truncate to only use the first 8
* characters or so in order to reduce the length:
*
* 6Xoj0UXO
*
* Use .slice(0, 8) if you want reduce the size.
*/

const crypto = require('crypto');
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/post.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const request = require('supertest');
const crypto = require('crypto'); // for hashing email addresses
const hash = require('../../src/hash'); // for hashing email addresses

const app = require('../../src/app');

Expand Down Expand Up @@ -46,8 +46,8 @@ describe('POST /v1/fragments', () => {
expect(typeof res.body.fragment).toBe("object");

expect(res.body.fragment.id).toBeDefined();
const email = crypto.createHash('sha256').update("user1@email.com").digest('hex');
expect(res.body.fragment.ownerId).toBe(email);
const hashed_email = hash("user1@email.com");
expect(res.body.fragment.ownerId).toBe(hashed_email);
expect(res.body.fragment.created).toBeDefined();
expect(res.body.fragment.updated).toBeDefined();
expect(res.body.fragment.type).toBe("text/plain");
Expand Down

0 comments on commit 58c3747

Please sign in to comment.