|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
const mock = require('mock-fs')
|
|
|
|
|
|
|
|
|
|
const glob = require('../../../src/components/index/glob')
|
|
|
|
|
const should = require('should/as-function')
|
|
|
|
|
|
|
|
|
@ -6,6 +6,12 @@ describe('Index: glob', function () {
|
|
|
|
|
this.slow(500)
|
|
|
|
|
this.timeout(500)
|
|
|
|
|
|
|
|
|
|
// we require "mock-fs" inside the tests, otherwise it also affects other tests
|
|
|
|
|
var mock = null
|
|
|
|
|
before(() => {
|
|
|
|
|
mock = require('mock-fs')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
mock.restore()
|
|
|
|
|
})
|
|
|
|
@ -56,16 +62,34 @@ describe('Index: glob', function () {
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('ignores folders starting with a dot', (done) => {
|
|
|
|
|
it('ignores any folder starting with a dot', (done) => {
|
|
|
|
|
mock({
|
|
|
|
|
'media/IMG_0001.JPG': '...',
|
|
|
|
|
'media/.git/IMG_0002.JPG': '...'
|
|
|
|
|
'media/IMG_0001.jpg': '...',
|
|
|
|
|
'media/.git/IMG_0002.jpg': '...',
|
|
|
|
|
'media/nested/.private/IMG_0003.jpg': '...',
|
|
|
|
|
'media/just/a.dot/IMG_0004.jpg': '...'
|
|
|
|
|
})
|
|
|
|
|
glob.find('media', (err, map) => {
|
|
|
|
|
if (err) return done(err)
|
|
|
|
|
const keys = Object.keys(map).sort()
|
|
|
|
|
should(keys).eql([
|
|
|
|
|
'IMG_0001.JPG'
|
|
|
|
|
'IMG_0001.jpg',
|
|
|
|
|
'just/a.dot/IMG_0004.jpg'
|
|
|
|
|
])
|
|
|
|
|
done()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('ignores folders called @eaDir (Synology thumbnail folders)', (done) => {
|
|
|
|
|
mock({
|
|
|
|
|
'media/holidays/IMG_0001.jpg': '...',
|
|
|
|
|
'media/holidays/@eaDir/IMG_0001.jpg': '...'
|
|
|
|
|
})
|
|
|
|
|
glob.find('media', (err, map) => {
|
|
|
|
|
if (err) return done(err)
|
|
|
|
|
const keys = Object.keys(map).sort()
|
|
|
|
|
should(keys).eql([
|
|
|
|
|
'holidays/IMG_0001.jpg'
|
|
|
|
|
])
|
|
|
|
|
done()
|
|
|
|
|
})
|
|
|
|
|