All files / src/rules element-permitted-order.spec.ts

100% Statements 18/18
100% Branches 0/0
100% Functions 6/6
100% Lines 18/18
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 371x   1x   1x       1x 1x         1x 1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x        
import HtmlValidate from '../htmlvalidate';
 
describe('rule element-permitted-order', function(){
 
	const expect = require('chai').expect;
 
	let htmlvalidate: HtmlValidate;
 
	before(function(){
		htmlvalidate = new HtmlValidate({
			rules: {'element-permitted-order': 'error'},
		});
	});
 
	it('should report error when child is used in wrong order', function(){
		const report = htmlvalidate.validateString('<table><thead></thead><caption></caption></table>');
		expect(report).to.be.invalid;
		expect(report).to.have.error('element-permitted-order', 'Element <caption> must be used before <thead> in this context');
	});
 
	it('should not report error when child is used in right order', function(){
		const report = htmlvalidate.validateString('<table><caption></caption><thead></thead></table>');
		expect(report).to.be.valid;
	});
 
	it('should not report error when disallowed child is used', function(){
		const report = htmlvalidate.validateString('<table><foo></foo></table>');
		expect(report).to.be.valid;
	});
 
	it('should not report error when child with unspecified order is used', function(){
		const report = htmlvalidate.validateString('<table><caption></caption><template></template><thead></thead></table>');
		expect(report).to.be.valid;
	});
 
});