From ec6fbf9b0a550bed5b95372f75a541b58765c23a Mon Sep 17 00:00:00 2001 From: Romain Date: Tue, 8 Jan 2019 21:53:20 +0100 Subject: [PATCH] test(database): more unit tests for file globbing patterns --- test/components/index/glob.spec.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/components/index/glob.spec.js b/test/components/index/glob.spec.js index 8ef8545..9e8934c 100644 --- a/test/components/index/glob.spec.js +++ b/test/components/index/glob.spec.js @@ -26,6 +26,33 @@ describe('Index: glob', function () { require('micromatch').match('file.txt', '**/**') }) + it('uses a valid glob pattern to filter files', () => { + const pattern = glob.globPattern({}) + should(pattern).startWith('**/*.{') + should(pattern).endWith('}') + }) + + it('can include photo extensions', () => { + const pattern = glob.globPattern({ includePhotos: true, includeVideos: false, includeRawPhotos: false }) + should(pattern.indexOf('jpg')).above(-1) + should(pattern.indexOf('mp4')).eql(-1) + should(pattern.indexOf('cr2')).eql(-1) + }) + + it('can include video extensions', () => { + const pattern = glob.globPattern({ includePhotos: false, includeVideos: true, includeRawPhotos: false }) + should(pattern.indexOf('jpg')).eql(-1) + should(pattern.indexOf('mp4')).above(-1) + should(pattern.indexOf('cr2')).eql(-1) + }) + + it('can include raw photo extensions', () => { + const pattern = glob.globPattern({ includePhotos: false, includeVideos: false, includeRawPhotos: true }) + should(pattern.indexOf('jpg')).eql(-1) + should(pattern.indexOf('mp4')).eql(-1) + should(pattern.indexOf('cr2')).above(-1) + }) + it('can list top-level images', (done) => { mock({ 'media/IMG_0001.jpg': '...',