2
0
mirror of https://github.com/thumbsup/thumbsup synced 2024-11-11 07:10:26 +00:00
thumbsup/test/input/file.spec.js

47 lines
1.1 KiB
JavaScript

const should = require('should/as-function')
const File = require('../../src/input/file')
describe('Input file', function () {
it('reads the relative file path', function () {
var file = new File(dbFile({
SourceFile: 'holidays/beach.jpg'
}))
should(file.path).eql('holidays/beach.jpg')
})
it('parses the file modification date', function () {
var file = new File(dbFile({
File: {
FileModifyDate: '2017:01:27 14:38:29+05:00'
}
}))
should(file.date).eql(1485509909000)
})
it('can guess the media type for photos', function () {
var file = new File(dbFile({
File: {
MIMEType: 'image/jpeg'
}
}))
should(file.type).eql('image')
})
it('can guess the media type for videos', function () {
var file = new File(dbFile({
File: {
MIMEType: 'video/quicktime'
}
}))
should(file.type).eql('video')
})
})
function dbFile (data) {
// some required data
if (!data.SourceFile) data.SourceFile = 'photo.jpg'
if (!data.File) data.File = {}
if (!data.File.FileModifyDate) data.File.FileModifyDate = '1999:12:31 23:59:59+00:00'
return data
}