All files / src/rules no-deprecated-attr.spec.ts

100% Statements 22/22
100% Branches 0/0
100% Functions 7/7
100% Lines 22/22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 431x   1x   1x       1x 1x         1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x        
import HtmlValidate from '../htmlvalidate';
 
describe('rule no-deprecated-attr', function() {
 
	const expect = require('chai').expect;
 
	let htmlvalidate: HtmlValidate;
 
	before(function() {
		htmlvalidate = new HtmlValidate({
			rules: { 'no-deprecated-attr': 'error' },
		});
	});
 
	it('should not report when regular element is used', function() {
		const report = htmlvalidate.validateString('<body style="background: red;"></body>');
		expect(report).to.be.valid;
	});
 
	it('should not report when regular element is missing meta', function() {
		const report = htmlvalidate.validateString('<any style="background: red;"></any>');
		expect(report).to.be.valid;
	});
 
	it('should not report when regular element has no deprecated attributes', function() {
		const report = htmlvalidate.validateString('<abbr style="background: red;"></abbr>');
		expect(report).to.be.valid;
	});
 
	it('should report error when deprecated attribute is used', function() {
		const report = htmlvalidate.validateString('<body bgcolor="red"></body>');
		expect(report).to.be.invalid;
		expect(report).to.have.error('no-deprecated-attr', 'Attribute "bgcolor" is deprecated on <body> element');
	});
 
	it('should report error when deprecated attribute is used in any case', function() {
		const report = htmlvalidate.validateString('<body BGCOLOR="red"></body>');
		expect(report).to.be.invalid;
		expect(report).to.have.error('no-deprecated-attr', 'Attribute "BGCOLOR" is deprecated on <body> element');
	});
 
});