Skip to content

Commit e86ccf3

Browse files
Added test to verify fetchProfileDiffUnobfuscated
1 parent f2f755c commit e86ccf3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* This eslint rule is disabled because of https://github.com/nodesecurity/eslint-plugin-security/issues/21
3+
* It gives linting errors in testing the DB data with keys from fixtures
4+
*/
5+
/* eslint-disable security/detect-object-injection */
6+
7+
const chai = require("chai");
8+
const { expect } = chai;
9+
const cleanDb = require("../../utils/cleanDb");
10+
const profileDiffsQuery = require("../../../models/profileDiffs");
11+
const getProfileDiffs = require("../../fixtures/profileDiffs/profileDiffs");
12+
13+
describe("profileDiffs", function () {
14+
afterEach(async function () {
15+
await cleanDb();
16+
});
17+
18+
describe("fetchProfileDiffUnobfuscated", function () {
19+
it("should return profileDiffs with unobfuscated email and phone", async function () {
20+
const profileDiffs = getProfileDiffs();
21+
const profileDiffId = await profileDiffsQuery.add(profileDiffs[0]);
22+
const diff = await profileDiffsQuery.fetchProfileDiffUnobfuscated(profileDiffId);
23+
expect(diff.phone).to.match(/^(\+\d{1,3}[- ]?)?\d{7,10}$/);
24+
expect(diff.email).to.match(/^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,}$/i);
25+
});
26+
});
27+
});

0 commit comments

Comments
 (0)