From bb058798f58280e0e34686fe59fa1852dfe0e9c4 Mon Sep 17 00:00:00 2001 From: Glen Date: Sat, 16 Jan 2016 19:26:30 +0200 Subject: [PATCH] Add more tests --- micromatch/micromatch-tests.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/micromatch/micromatch-tests.ts b/micromatch/micromatch-tests.ts index 2b0c8d784..75f9407ee 100644 --- a/micromatch/micromatch-tests.ts +++ b/micromatch/micromatch-tests.ts @@ -1,15 +1,17 @@ /// import mm = require('micromatch'); -var result: string[]; +var strArrResult: string[]; var boolResult: boolean; +var strMatchFuncResult: mm.MatchFunction; +var anyMatchFuncResult: mm.MatchFunction; var regExpResult: RegExp; // Usage. -result = mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}'); +strArrResult = mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}'); // Multiple patterns. -result = mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']); +strArrResult = mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']); // "isMatch" method. boolResult = mm.isMatch('.verb.md', '*.md'); @@ -21,11 +23,21 @@ 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'); +strMatchFuncResult = mm.matcher('*.md'); +strMatchFuncResult = mm.matcher(/\.md$/); +strMatchFuncResult = mm.matcher((filePath: string) => true); // "filter" method. -var fn = mm.filter('*.md'); -var fn = mm.filter('*.md', {dot: true}); +anyMatchFuncResult = mm.filter('*.md'); +anyMatchFuncResult = mm.filter(/\.md$/); +anyMatchFuncResult = mm.filter((filePath: string) => true); + +anyMatchFuncResult = mm.filter('*.md', {dot: true}); +['a.js', 'b.txt', 'c.md'].filter(anyMatchFuncResult); + +var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 , 11, 12, 13, 14, 15]; +anyMatchFuncResult = mm.filter(['{1..10}', '![7-9]', '!{3..4}']); +arr.filter(anyMatchFuncResult); // "any" method. boolResult = mm.any('abc', ['!*z']);