2017-12-23 09:32:10 +00:00
|
|
|
const should = require('should/as-function')
|
|
|
|
const AlbumMapper = require('../../src/input/album-mapper.js')
|
|
|
|
const fixtures = require('../fixtures.js')
|
|
|
|
|
|
|
|
const TEST_FILE = fixtures.photo({
|
|
|
|
path: 'Holidays/IMG_0001.jpg',
|
|
|
|
date: '2016:07:14 12:07:41'
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Album mapper', function () {
|
|
|
|
it('can use a single string pattern', function () {
|
2017-12-22 21:37:08 +00:00
|
|
|
const mapper = new AlbumMapper(['%path'])
|
2017-12-23 09:32:10 +00:00
|
|
|
should(mapper.getAlbums(TEST_FILE)).eql(['Holidays'])
|
|
|
|
})
|
|
|
|
it('can use a single function (for testing)', function () {
|
|
|
|
const custom = file => 'hello'
|
2017-12-22 21:37:08 +00:00
|
|
|
const mapper = new AlbumMapper([custom])
|
2017-12-23 09:32:10 +00:00
|
|
|
should(mapper.getAlbums(TEST_FILE)).eql(['hello'])
|
|
|
|
})
|
|
|
|
it('can provide multiple string patterns', function () {
|
2017-12-22 21:37:08 +00:00
|
|
|
const mapper = new AlbumMapper(['%path', '{YYYY}'])
|
2017-12-23 09:32:10 +00:00
|
|
|
should(mapper.getAlbums(TEST_FILE)).eql(['Holidays', '2016'])
|
|
|
|
})
|
|
|
|
it('merges all albums into a single array', function () {
|
|
|
|
const custom1 = file => ['one']
|
|
|
|
const custom2 = file => ['two', 'three']
|
2017-12-22 21:37:08 +00:00
|
|
|
const mapper = new AlbumMapper([custom1, custom2])
|
2017-12-23 09:32:10 +00:00
|
|
|
should(mapper.getAlbums(TEST_FILE)).eql(['one', 'two', 'three'])
|
|
|
|
})
|
2017-12-22 21:37:08 +00:00
|
|
|
it('defaults to %path if no patterns are specified', () => {
|
|
|
|
const mapper = new AlbumMapper()
|
|
|
|
should(mapper.getAlbums(TEST_FILE)).eql(['Holidays'])
|
2017-12-23 09:32:10 +00:00
|
|
|
})
|
|
|
|
})
|