mirror of https://github.com/thumbsup/thumbsup
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
const path = require('path')
|
|
const should = require('should/as-function')
|
|
const fixtures = require('../../fixtures')
|
|
const exiftool = require('../../../src/components/exiftool/parallel')
|
|
|
|
describe('exiftool', function () {
|
|
this.slow(1000)
|
|
this.timeout(1000)
|
|
|
|
it('processes all files', (done) => {
|
|
// generate some photos in a temp folder
|
|
const image = fixtures.fromDisk('photo.jpg')
|
|
const structure = {}
|
|
for (let i = 0; i < 10; ++i) {
|
|
structure[`IMG_00${i}.jpg`] = image
|
|
}
|
|
const tmpdir = fixtures.createTempStructure(structure)
|
|
// process them in batch
|
|
const processed = []
|
|
const stream = exiftool.parse(tmpdir, Object.keys(structure))
|
|
stream.on('data', entry => {
|
|
// <entry> should be the deserialized JSON output from exiftool
|
|
processed.push(entry.SourceFile)
|
|
}).on('end', () => {
|
|
const expected = Object.keys(structure).sort()
|
|
should(processed.sort()).eql(expected)
|
|
done()
|
|
})
|
|
})
|
|
|
|
it('can process badly encoded fields', (done) => {
|
|
// here we test with an XMP file because it's easier to see what's wrong
|
|
// but the problem will more likely be with a badly encoded XMP section inside a JPG file
|
|
// note: use <vi> to edit <bad-encoding.xmp> if required, to avoid converting it to UTF
|
|
const testFixtures = path.join(__dirname, '..', '..', '..', 'test-fixtures')
|
|
const stream = exiftool.parse(testFixtures, ['bad-encoding.xmp'])
|
|
const processed = []
|
|
stream.on('data', entry => {
|
|
processed.push(entry.SourceFile)
|
|
}).on('end', () => {
|
|
should(processed).eql(['bad-encoding.xmp'])
|
|
done()
|
|
})
|
|
})
|
|
})
|