Improve tests

This commit is contained in:
Glen
2016-01-10 13:12:55 +02:00
parent da35ad861d
commit 4e75dc7afa
2 changed files with 38 additions and 26 deletions

View File

@@ -1,32 +1,41 @@
/// <reference path="./micromatch.d.ts"/>
import mm = require('micromatch');
var result: string[];
var boolResult: boolean;
var regExpResult: RegExp;
// Usage.
mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}');
result = mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}');
// Multiple patterns.
mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']);
result = mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']);
// "isMatch" method.
mm.isMatch('.verb.md', '*.md');
mm.isMatch('.verb.md', '*.md', {dot: true});
mm.isMatch('.verb.md', {dot: true});
boolResult = mm.isMatch('.verb.md', '*.md');
boolResult = mm.isMatch('.verb.md', '*.md', {dot: true});
boolResult = mm.isMatch('*.md', {dot: true})('.verb.md');
// "contains" method.
mm.contains('a/b/c', 'a/b');
boolResult = mm.contains('a/b/c', 'a/b');
boolResult = mm.contains('a/b/c', 'a/b', {dot: true});
// "matcher" method.
var isMatch = mm.matcher('*.md');
// "filter" method.
var fn = mm.filter('*.md');
var fn = mm.filter('*.md', {dot: true});
// "any" method.
mm.any('abc', ['!*z']);
mm.any('abc', 'a*');
boolResult = mm.any('abc', ['!*z']);
boolResult = mm.any('abc', 'a*');
boolResult = mm.any('abc', 'a*', {dot: true});
// "expand" method.
mm.expand('*.js');
mm.expand('*.js', {dot: true});
// "makeRe" method.
mm.makeRe('*.js');
regExpResult = mm.makeRe('*.js');
regExpResult = mm.makeRe('*.js', {dot: true});

View File

@@ -1,21 +1,24 @@
/// <reference path="./parse-glob.d.ts"/>
import parseGlob = require('parse-glob');
var result = parseGlob('a/b/c/**/*.{yml,json}');
var result: ParseGlob.Result = parseGlob('a/b/c/**/*.{yml,json}');
result.base;
result.glob;
result.is.braces;
result.is.brackets;
result.is.dotdir;
result.is.dotfile;
result.is.extglob;
result.is.glob;
result.is.globstar;
result.is.negated;
result.orig;
result.path.basename;
result.path.dirname;
result.path.ext;
result.path.extname;
result.path.filename;
var stringValue: string;
var boolValue: boolean;
stringValue = result.base;
stringValue = result.glob;
boolValue = result.is.braces;
boolValue = result.is.brackets;
boolValue = result.is.dotdir;
boolValue = result.is.dotfile;
boolValue = result.is.extglob;
boolValue = result.is.glob;
boolValue = result.is.globstar;
boolValue = result.is.negated;
stringValue = result.orig;
stringValue = result.path.basename;
stringValue = result.path.dirname;
stringValue = result.path.ext;
stringValue = result.path.extname;
stringValue = result.path.filename;