All files / src/dom combinator.spec.ts

100% Statements 18/18
100% Branches 0/0
100% Functions 7/7
100% Lines 17/17
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 321x   1x   1x   1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x        
import { Combinator, parseCombinator } from 'dom/combinator';
 
describe('DOM Combinator', function(){
 
	const expect = require('chai').expect;
 
	it('should default to descendant combinator', function(){
		const result = parseCombinator('');
		expect(result).to.equal(Combinator.DESCENDANT);
	});
 
	it('should parse > as child combinator', function(){
		const result = parseCombinator('>');
		expect(result).to.equal(Combinator.CHILD);
	});
 
	it('should parse + as adjacent sibling combinator', function(){
		const result = parseCombinator('+');
		expect(result).to.equal(Combinator.ADJACENT_SIBLING);
	});
 
	it('should parse + as general sibling combinator', function(){
		const result = parseCombinator('~');
		expect(result).to.equal(Combinator.GENERAL_SIBLING);
	});
 
	it('should throw error on invalid combinator', function(){
		expect(() => parseCombinator('a')).to.throw();
	});
 
});