|
|
@ -1,77 +1,79 @@
|
|
|
|
const _ = require('lodash')
|
|
|
|
const _ = require('lodash')
|
|
|
|
const should = require('should/as-function')
|
|
|
|
const should = require('should/as-function')
|
|
|
|
const structure = require('../../src/model/structure')
|
|
|
|
const structure = require('../../src/model/structure')
|
|
|
|
|
|
|
|
const fixtures = require('../fixtures.js')
|
|
|
|
|
|
|
|
|
|
|
|
const folders = structure.folders
|
|
|
|
const folders = structure.folders
|
|
|
|
const suffix = structure.suffix
|
|
|
|
const suffix = structure.suffix
|
|
|
|
|
|
|
|
const ospath = fixtures.ospath
|
|
|
|
|
|
|
|
|
|
|
|
describe('Structure', () => {
|
|
|
|
describe('Structure', () => {
|
|
|
|
describe('folders', () => {
|
|
|
|
describe('folders', () => {
|
|
|
|
it('starts with <media>', () => {
|
|
|
|
it('starts with <media>', () => {
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:thumbnail')).startWith('media/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:thumbnail')).startWith(ospath('media/'))
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:large')).startWith('media/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:large')).startWith(ospath('media/'))
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:thumbnail')).startWith('media/')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:thumbnail')).startWith(ospath('media/'))
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:poster')).startWith('media/')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:poster')).startWith(ospath('media/'))
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:resized')).startWith('media/')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:resized')).startWith(ospath('media/'))
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:copy')).startWith('media/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:copy')).startWith(ospath('media/'))
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:symlink')).startWith('media/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:symlink')).startWith(ospath('media/'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('can be at the root', () => {
|
|
|
|
it('can be at the root', () => {
|
|
|
|
should(folders('IMG_0001.jpg', 'photo:thumbnail')).eql('media/thumbs/IMG_0001.jpg')
|
|
|
|
should(folders('IMG_0001.jpg', 'photo:thumbnail')).eql(ospath('media/thumbs/IMG_0001.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('adds thumbnails to a <thumbs> folder', () => {
|
|
|
|
it('adds thumbnails to a <thumbs> folder', () => {
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:thumbnail')).startWith('media/thumbs/holidays/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:thumbnail')).startWith(ospath('media/thumbs/holidays/'))
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:thumbnail')).startWith('media/thumbs/holidays/')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:thumbnail')).startWith(ospath('media/thumbs/holidays/'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('adds large versions to a <large> folder', () => {
|
|
|
|
it('adds large versions to a <large> folder', () => {
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:large')).startWith('media/large/holidays/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:large')).startWith(ospath('media/large/holidays/'))
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:poster')).startWith('media/large/holidays/')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:poster')).startWith(ospath('media/large/holidays/'))
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:resized')).startWith('media/large/holidays/')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:resized')).startWith(ospath('media/large/holidays/'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('adds copies and links to an <original> folder', () => {
|
|
|
|
it('adds copies and links to an <original> folder', () => {
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:copy')).startWith('media/original/holidays/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:copy')).startWith(ospath('media/original/holidays/'))
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:symlink')).startWith('media/original/holidays/')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:symlink')).startWith(ospath('media/original/holidays/'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('keeps the full original name for copies and links', () => {
|
|
|
|
it('keeps the full original name for copies and links', () => {
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:copy')).endWith('IMG_0001.jpg')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:copy')).endWith(ospath('IMG_0001.jpg'))
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:symlink')).endWith('IMG_0001.jpg')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'fs:symlink')).endWith(ospath('IMG_0001.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('preserves the photo thumbnail extension if supported', () => {
|
|
|
|
it('preserves the photo thumbnail extension if supported', () => {
|
|
|
|
// lower case
|
|
|
|
// lower case
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:thumbnail')).endWith('IMG_0001.jpg')
|
|
|
|
should(folders('holidays/IMG_0001.jpg', 'photo:thumbnail')).endWith(ospath('IMG_0001.jpg'))
|
|
|
|
should(folders('holidays/IMG_0001.jpeg', 'photo:thumbnail')).endWith('IMG_0001.jpeg')
|
|
|
|
should(folders('holidays/IMG_0001.jpeg', 'photo:thumbnail')).endWith(ospath('IMG_0001.jpeg'))
|
|
|
|
should(folders('holidays/IMG_0001.png', 'photo:thumbnail')).endWith('IMG_0001.png')
|
|
|
|
should(folders('holidays/IMG_0001.png', 'photo:thumbnail')).endWith(ospath('IMG_0001.png'))
|
|
|
|
should(folders('holidays/IMG_0001.gif', 'photo:thumbnail')).endWith('IMG_0001.gif')
|
|
|
|
should(folders('holidays/IMG_0001.gif', 'photo:thumbnail')).endWith(ospath('IMG_0001.gif'))
|
|
|
|
// upper case
|
|
|
|
// upper case
|
|
|
|
should(folders('holidays/IMG_0001.JPG', 'photo:thumbnail')).endWith('IMG_0001.JPG')
|
|
|
|
should(folders('holidays/IMG_0001.JPG', 'photo:thumbnail')).endWith(ospath(ospath('IMG_0001.JPG')))
|
|
|
|
should(folders('holidays/IMG_0001.JPEG', 'photo:thumbnail')).endWith('IMG_0001.JPEG')
|
|
|
|
should(folders('holidays/IMG_0001.JPEG', 'photo:thumbnail')).endWith(ospath(ospath('IMG_0001.JPEG')))
|
|
|
|
should(folders('holidays/IMG_0001.PNG', 'photo:thumbnail')).endWith('IMG_0001.PNG')
|
|
|
|
should(folders('holidays/IMG_0001.PNG', 'photo:thumbnail')).endWith(ospath(ospath('IMG_0001.PNG')))
|
|
|
|
should(folders('holidays/IMG_0001.GIF', 'photo:thumbnail')).endWith('IMG_0001.GIF')
|
|
|
|
should(folders('holidays/IMG_0001.GIF', 'photo:thumbnail')).endWith(ospath(ospath('IMG_0001.GIF')))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('changes the photo thumbnail extension to jpg if not supported', () => {
|
|
|
|
it('changes the photo thumbnail extension to jpg if not supported', () => {
|
|
|
|
should(folders('holidays/IMG_0001.tiff', 'photo:thumbnail')).endWith('IMG_0001.jpg')
|
|
|
|
should(folders('holidays/IMG_0001.tiff', 'photo:thumbnail')).endWith(ospath(ospath('IMG_0001.jpg')))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('supports two different resized video extensions', () => {
|
|
|
|
it('supports two different resized video extensions', () => {
|
|
|
|
should(folders('holidays/IMG_0001.mov', 'video:resized', { videoFormat: 'mp4' })).endWith('IMG_0001.mp4')
|
|
|
|
should(folders('holidays/IMG_0001.mov', 'video:resized', { videoFormat: 'mp4' })).endWith(ospath('IMG_0001.mp4'))
|
|
|
|
should(folders('holidays/IMG_0001.mov', 'video:resized', { videoFormat: 'webm' })).endWith('IMG_0001.webm')
|
|
|
|
should(folders('holidays/IMG_0001.mov', 'video:resized', { videoFormat: 'webm' })).endWith(ospath('IMG_0001.webm'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('always uses jpg for video thumbnails and posters', () => {
|
|
|
|
it('always uses jpg for video thumbnails and posters', () => {
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:thumbnail')).endWith('IMG_0001.jpg')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:thumbnail')).endWith(ospath('IMG_0001.jpg'))
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:poster')).endWith('IMG_0001.jpg')
|
|
|
|
should(folders('holidays/IMG_0001.mp4', 'video:poster')).endWith(ospath('IMG_0001.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('can use a file system link', () => {
|
|
|
|
it('can use a file system link', () => {
|
|
|
|
const res = folders('holidays/IMG_0001.jpg', 'fs:link', { linkPrefix: '../..' })
|
|
|
|
const res = folders('holidays/IMG_0001.jpg', 'fs:link', { linkPrefix: '../..' })
|
|
|
|
should(res).eql('../../holidays/IMG_0001.jpg')
|
|
|
|
should(res).eql(ospath('../../holidays/IMG_0001.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('can use a remote HTTP link', () => {
|
|
|
|
it('can use a remote HTTP link', () => {
|
|
|
@ -82,36 +84,36 @@ describe('Structure', () => {
|
|
|
|
|
|
|
|
|
|
|
|
describe('suffix', () => {
|
|
|
|
describe('suffix', () => {
|
|
|
|
it('starts with <media>', () => {
|
|
|
|
it('starts with <media>', () => {
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:thumbnail')).startWith('media/')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:thumbnail')).startWith(ospath('media/'))
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:large')).startWith('media/')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:large')).startWith(ospath('media/'))
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:thumbnail')).startWith('media/')
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:thumbnail')).startWith(ospath('media/'))
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:poster')).startWith('media/')
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:poster')).startWith(ospath('media/'))
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:resized')).startWith('media/')
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:resized')).startWith(ospath('media/'))
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:copy')).startWith('media/')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:copy')).startWith(ospath('media/'))
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:symlink')).startWith('media/')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:symlink')).startWith(ospath('media/'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('can be at the root', () => {
|
|
|
|
it('can be at the root', () => {
|
|
|
|
should(suffix('IMG_0001.jpg', 'photo:thumbnail')).eql('media/IMG_0001_jpg_thumb.jpg')
|
|
|
|
should(suffix('IMG_0001.jpg', 'photo:thumbnail')).eql(ospath('media/IMG_0001_jpg_thumb.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('uses an _thumb suffix to denote thumbnails', () => {
|
|
|
|
it('uses an _thumb suffix to denote thumbnails', () => {
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:thumbnail')).endWith('holidays/IMG_0001_jpg_thumb.jpg')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:thumbnail')).endWith(ospath('holidays/IMG_0001_jpg_thumb.jpg'))
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:thumbnail')).endWith('holidays/IMG_0001_mp4_thumb.jpg')
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:thumbnail')).endWith(ospath('holidays/IMG_0001_mp4_thumb.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('uses a _large suffix to resized versions', () => {
|
|
|
|
it('uses a _large suffix to resized versions', () => {
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:large')).endWith('holidays/IMG_0001_jpg_large.jpg')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'photo:large')).endWith(ospath('holidays/IMG_0001_jpg_large.jpg'))
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:resized')).endWith('holidays/IMG_0001_mp4_large.mp4')
|
|
|
|
should(suffix('holidays/IMG_0001.mp4', 'video:resized')).endWith(ospath('holidays/IMG_0001_mp4_large.mp4'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('uses a _poster suffix for the video poster', () => {
|
|
|
|
it('uses a _poster suffix for the video poster', () => {
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'video:poster')).endWith('holidays/IMG_0001_jpg_poster.jpg')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'video:poster')).endWith(ospath('holidays/IMG_0001_jpg_poster.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('uses the original filenames for copies and symlinks', () => {
|
|
|
|
it('uses the original filenames for copies and symlinks', () => {
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:copy')).endWith('holidays/IMG_0001.jpg')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:copy')).endWith(ospath('holidays/IMG_0001.jpg'))
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:symlink')).endWith('holidays/IMG_0001.jpg')
|
|
|
|
should(suffix('holidays/IMG_0001.jpg', 'fs:symlink')).endWith(ospath('holidays/IMG_0001.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('does not have conflicts between generated photo and video files', () => {
|
|
|
|
it('does not have conflicts between generated photo and video files', () => {
|
|
|
@ -128,7 +130,7 @@ describe('Structure', () => {
|
|
|
|
|
|
|
|
|
|
|
|
it('can use a file system link', () => {
|
|
|
|
it('can use a file system link', () => {
|
|
|
|
const res = suffix('holidays/IMG_0001.jpg', 'fs:link', { linkPrefix: '../..' })
|
|
|
|
const res = suffix('holidays/IMG_0001.jpg', 'fs:link', { linkPrefix: '../..' })
|
|
|
|
should(res).eql('../../holidays/IMG_0001.jpg')
|
|
|
|
should(res).eql(ospath('../../holidays/IMG_0001.jpg'))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
it('can use a remote HTTP link', () => {
|
|
|
|
it('can use a remote HTTP link', () => {
|
|
|
|