Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should allow audio tags with some attributes', () => {
const audio =
'<audio src="my/audio.ogg autoplay loop ' + 'controls muted"></audio>';
expect(defaultSanitizer.sanitize(audio)).to.equal(audio);
});
it('should strip link tags', () => {
const link = '';
expect(defaultSanitizer.sanitize(link)).to.equal('');
});
it('should allow the class attribute for code tags', () => {
const code = '<code class="foo">bar</code>';
expect(defaultSanitizer.sanitize(code)).to.equal(code);
});
it('should allow img tags and some attributes', () => {
const img =
'<img width="42" height="42" alt="Smiley face" src="smiley.gif">';
expect(defaultSanitizer.sanitize(img)).to.equal(img);
});
it("should strip 'orphans' properties from inline CSS", () => {
const div = '<div style="orphans: 3;"></div>';
expect(defaultSanitizer.sanitize(div)).to.equal('<div></div>');
});
});
it('should allow audio tags with some attributes', () => {
const audio =
'<audio src="my/audio.ogg autoplay loop ' + 'controls muted"></audio>';
expect(defaultSanitizer.sanitize(audio)).to.equal(audio);
});
it('should allow h1 tags', () => {
const h1 = '<h1>foo</h1>';
expect(defaultSanitizer.sanitize(h1)).to.equal(h1);
});
it("should strip 'content' properties from inline CSS", () => {
const div = '<div style="color: green; content: attr(title)"></div>';
expect(defaultSanitizer.sanitize(div)).to.equal(
'<div style="color:green"></div>'
);
});
it('should set the rel attribute for <a> tags to "nofollow', () => {
const a = '</a><a href="bar" rel="foo">Baz</a>';
const expected = a.replace('foo', 'nofollow');
expect(defaultSanitizer.sanitize(a)).to.equal(expected);
});
it('should allow span tags and class attribute', () => {
const span = '<span class="foo">bar</span>';
expect(defaultSanitizer.sanitize(span)).to.equal(span);
});