|
Jared K. Smith |
45afa13 |
/*!
|
|
Jared K. Smith |
45afa13 |
* dotfile-regex <https://github.com/regexps/dotfile-regex>
|
|
Jared K. Smith |
45afa13 |
*
|
|
Jared K. Smith |
45afa13 |
* Copyright (c) 2015 Jon Schlinkert.
|
|
Jared K. Smith |
45afa13 |
* Licensed under the MIT License
|
|
Jared K. Smith |
45afa13 |
*/
|
|
Jared K. Smith |
45afa13 |
|
|
Jared K. Smith |
45afa13 |
'use strict';
|
|
Jared K. Smith |
45afa13 |
|
|
Jared K. Smith |
45afa13 |
var assert = require('assert');
|
|
Jared K. Smith |
45afa13 |
var re = require('./')();
|
|
Jared K. Smith |
45afa13 |
|
|
Jared K. Smith |
45afa13 |
it('should match dotfiles', function () {
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/b/c/d/.gitignore')[0], '/.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/b/c/d/.gitignore')[1], '.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/.b/c/.gitignore')[0], '/.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/.b/c/.gitignore')[1], '.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/.gitignore')[0], '/.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/.gitignore')[1], '.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('.gitignore')[0], '.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('.gitignore')[1], '.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('/.gitignore')[0], '/.gitignore');
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('/.gitignore')[1], '.gitignore');
|
|
Jared K. Smith |
45afa13 |
});
|
|
Jared K. Smith |
45afa13 |
|
|
Jared K. Smith |
45afa13 |
it('should not match non-dotfiles', function () {
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/b/c/d/e.js'), null);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/b.c.d/e.js'), null);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/b.js'), null);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('a/.b/c/a.js'), null);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.exec('.gitignore/foo'), null);
|
|
Jared K. Smith |
45afa13 |
});
|
|
Jared K. Smith |
45afa13 |
|
|
Jared K. Smith |
45afa13 |
it('should return false when the file is not a dotfile', function () {
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('a/b/c/d/e.js'), false);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('a/b.c.d/e.js'), false);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('a/b.js'), false);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('a/.b/c/a.js'), false);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('.gitignore/foo'), false);
|
|
Jared K. Smith |
45afa13 |
});
|
|
Jared K. Smith |
45afa13 |
|
|
Jared K. Smith |
45afa13 |
it('should return true when the file is a dotfile', function () {
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('a/b/c/d/.gitignore'), true);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('a/.b/c/.gitignore'), true);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('a/.gitignore'), true);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('.gitignore'), true);
|
|
Jared K. Smith |
45afa13 |
assert.equal(re.test('/.gitignore'), true);
|
|
Jared K. Smith |
45afa13 |
});
|