Minor test update

This commit is contained in:
Dominik Prokop 2019-12-17 13:44:32 +01:00
parent cba7892d8e
commit 2eccdb4770
2 changed files with 7 additions and 4 deletions

View File

@ -211,7 +211,6 @@ export class LinkSrv implements LinkService {
value: variablesQuery, value: variablesQuery,
}, },
}); });
info.href = getConfig().disableSanitizeHtml ? info.href : sanitizeUrl(info.href); info.href = getConfig().disableSanitizeHtml ? info.href : sanitizeUrl(info.href);
return info; return info;
}; };

View File

@ -140,6 +140,12 @@ describe('linkSrv', () => {
}); });
describe('sanitization', () => { describe('sanitization', () => {
let restoreConfig: () => void;
afterEach(() => {
restoreConfig();
});
const url = "javascript:alert('broken!);"; const url = "javascript:alert('broken!);";
it.each` it.each`
disableSanitizeHtml | expected disableSanitizeHtml | expected
@ -148,7 +154,7 @@ describe('linkSrv', () => {
`( `(
"when disable disableSanitizeHtml set to '$disableSanitizeHtml' then result should be '$expected'", "when disable disableSanitizeHtml set to '$disableSanitizeHtml' then result should be '$expected'",
({ disableSanitizeHtml, expected }) => { ({ disableSanitizeHtml, expected }) => {
const restoreConfig = mockConfig({ restoreConfig = mockConfig({
disableSanitizeHtml, disableSanitizeHtml,
}); });
@ -166,9 +172,7 @@ describe('linkSrv', () => {
{} {}
).href; ).href;
// console.log(link);
expect(link).toBe(expected); expect(link).toBe(expected);
restoreConfig();
} }
); );
}); });