From ee82327d2af24fc68a7611eb01a6365287526502 Mon Sep 17 00:00:00 2001 From: Jonathan Jogenfors Date: Wed, 3 Jan 2024 23:42:26 +0100 Subject: [PATCH] add tests for cli exclusion pattern (#6148) --- cli/src/services/crawl.service.spec.ts | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/cli/src/services/crawl.service.spec.ts b/cli/src/services/crawl.service.spec.ts index 4a30669d69..447b6edc9d 100644 --- a/cli/src/services/crawl.service.spec.ts +++ b/cli/src/services/crawl.service.spec.ts @@ -198,6 +198,58 @@ const tests: Test[] = [ [`/photos/3.jpg`]: false, }, }, + { + test: 'should support ignoring full filename', + options: { + pathsToCrawl: ['/photos'], + exclusionPatterns: ['**/image2.jpg'], + }, + files: { + '/photos/image1.jpg': true, + '/photos/image2.jpg': false, + '/photos/image3.jpg': true, + }, + }, + { + test: 'should support ignoring file extensions', + options: { + pathsToCrawl: ['/photos'], + exclusionPatterns: ['**/*.png'], + }, + files: { + '/photos/image1.jpg': true, + '/photos/image2.png': false, + '/photos/image3.jpg': true, + }, + }, + { + test: 'should support ignoring folder names', + options: { + pathsToCrawl: ['/photos'], + recursive: true, + exclusionPatterns: ['**/raw/**'], + }, + files: { + '/photos/image1.jpg': true, + '/photos/image/image1.jpg': true, + '/photos/raw/image2.dng': false, + '/photos/raw/image3.dng': false, + '/photos/notraw/image3.jpg': true, + }, + }, + { + test: 'should support ignoring absolute paths', + options: { + pathsToCrawl: ['/'], + recursive: true, + exclusionPatterns: ['/images/**'], + }, + files: { + '/photos/image1.jpg': true, + '/images/image2.jpg': false, + '/assets/image3.jpg': true, + }, + }, ]; describe(CrawlService.name, () => {