Skip to content

Commit

Permalink
test(util/sanitize): Improve test for sanitize function (#12860)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Nov 27, 2021
1 parent d1229b2 commit 562d4ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 0 additions & 3 deletions lib/util/__snapshots__/sanitize.spec.ts.snap

This file was deleted.

15 changes: 9 additions & 6 deletions lib/util/sanitize.spec.ts
Expand Up @@ -16,11 +16,14 @@ describe('util/sanitize', () => {
const hashed = Buffer.from(`${username}:${password}`).toString('base64');
add(hashed);
add(password);
// FIXME: explicit assert condition
expect(
sanitize(
`My token is ${token}, username is "${username}" and password is "${password}" (hashed: ${hashed})`
)
).toMatchSnapshot();

const input = `My token is ${token}, username is "${username}" and password is "${password}" (hashed: ${hashed})`;
const output =
'My token is **redacted**, username is "userabc" and password is "**redacted**" (hashed: **redacted**)';
expect(sanitize(input)).toBe(output);

const inputX2 = [input, input].join('\n');
const outputX2 = [output, output].join('\n');
expect(sanitize(inputX2)).toBe(outputX2);
});
});

0 comments on commit 562d4ef

Please sign in to comment.