All files / src pattern.spec.ts

100% Statements 26/26
100% Branches 0/0
100% Functions 5/5
100% Lines 26/26
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 391x   1x   1x   1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x        
import { parsePattern } from './pattern';
 
describe('Pattern', function(){
 
	const expect = require('chai').expect;
 
	it('kebabcase should match strings with dashes', function(){
		const pattern = parsePattern('kebabcase');
		expect('foo-bar').to.match(pattern);
		expect('fooBar').to.not.match(pattern);
		expect('Foobar').to.not.match(pattern);
		expect('foo_bar').to.not.match(pattern);
	});
 
	it('camelcase should match strings in camelcase', function(){
		const pattern = parsePattern('camelcase');
		expect('foo-bar').to.not.match(pattern);
		expect('fooBar').to.match(pattern);
		expect('Foobar').to.not.match(pattern);
		expect('foo_bar').to.not.match(pattern);
	});
 
	it('underscore should match strings with underscore', function(){
		const pattern = parsePattern('underscore');
		expect('foo-bar').to.not.match(pattern);
		expect('fooBar').to.not.match(pattern);
		expect('Foobar').to.not.match(pattern);
		expect('foo_bar').to.match(pattern);
	});
 
	it('should support user-supplied regexp', function(){
		const pattern = parsePattern('^foo-[a-z]\\w+$');
		expect('foo-bar').to.match(pattern);
		expect('bar-foo').to.not.match(pattern);
		expect('barfoo-baz').to.not.match(pattern);
	});
 
});