|
|
|
@ -4,6 +4,8 @@ const hierarchy = require('../../src/input/hierarchy.js')
|
|
|
|
|
const Album = require('../../src/model/album.js')
|
|
|
|
|
const fixtures = require('../fixtures')
|
|
|
|
|
|
|
|
|
|
const DEFAULT_OPTS = { homeAlbumName: 'Home' }
|
|
|
|
|
|
|
|
|
|
describe('hierarchy', function () {
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
Album.resetIds()
|
|
|
|
@ -12,20 +14,26 @@ describe('hierarchy', function () {
|
|
|
|
|
describe('root album', function () {
|
|
|
|
|
it('creates a root album (homepage) to put all sub-albums', function () {
|
|
|
|
|
const mapper = mockMapper(file => ['all'])
|
|
|
|
|
const home = hierarchy.createAlbums([], mapper, {})
|
|
|
|
|
const home = hierarchy.createAlbums([], mapper, DEFAULT_OPTS)
|
|
|
|
|
should(home.title).eql('Home')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('can configure the top-level album name', function () {
|
|
|
|
|
const mapper = mockMapper(file => ['all'])
|
|
|
|
|
const home = hierarchy.createAlbums([], mapper, { homeAlbumName: 'Holidays' })
|
|
|
|
|
should(home.title).eql('Holidays')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('defaults the homepage to index.html', function () {
|
|
|
|
|
const mapper = mockMapper(file => ['all'])
|
|
|
|
|
const home = hierarchy.createAlbums([], mapper, {})
|
|
|
|
|
const home = hierarchy.createAlbums([], mapper, DEFAULT_OPTS)
|
|
|
|
|
should(home.path).eql('index.html')
|
|
|
|
|
should(home.url).eql('index.html')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('can configure the homepage path', function () {
|
|
|
|
|
const mapper = mockMapper(file => ['all'])
|
|
|
|
|
const home = hierarchy.createAlbums([], mapper, { index: 'default.html' })
|
|
|
|
|
const home = hierarchy.createAlbums([], mapper, { homeAlbumName: 'Home', index: 'default.html' })
|
|
|
|
|
should(home.path).eql('default.html')
|
|
|
|
|
should(home.url).eql('default.html')
|
|
|
|
|
})
|
|
|
|
@ -40,7 +48,7 @@ describe('hierarchy', function () {
|
|
|
|
|
fixtures.photo({ path: 'IMG_000002.jpg' })
|
|
|
|
|
]
|
|
|
|
|
const mapper = mockMapper(file => [value])
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper)
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper, DEFAULT_OPTS)
|
|
|
|
|
should(home.albums.length).eql(0)
|
|
|
|
|
should(home.files.length).eql(2)
|
|
|
|
|
should(home.files[0].filename).eql('IMG_000001.jpg')
|
|
|
|
@ -56,7 +64,7 @@ describe('hierarchy', function () {
|
|
|
|
|
fixtures.photo({ path: 'IMG_000002.jpg' })
|
|
|
|
|
]
|
|
|
|
|
const mapper = mockMapper(file => ['all'])
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper)
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper, DEFAULT_OPTS)
|
|
|
|
|
should(home.albums.length).eql(1)
|
|
|
|
|
should(home.albums[0].title).eql('all')
|
|
|
|
|
should(home.albums[0].files).eql([files[0], files[1]])
|
|
|
|
@ -68,7 +76,7 @@ describe('hierarchy', function () {
|
|
|
|
|
fixtures.photo({ path: 'two/IMG_000002.jpg' })
|
|
|
|
|
]
|
|
|
|
|
const mapper = mockMapper(file => [path.dirname(file.path)])
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper)
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper, DEFAULT_OPTS)
|
|
|
|
|
should(home.albums.length).eql(2)
|
|
|
|
|
should(home.albums[0].title).eql('one')
|
|
|
|
|
should(home.albums[0].files).eql([files[0]])
|
|
|
|
@ -82,7 +90,7 @@ describe('hierarchy', function () {
|
|
|
|
|
fixtures.photo({ path: 'IMG_000002.jpg' })
|
|
|
|
|
]
|
|
|
|
|
const mapper = mockMapper(file => ['one/two'])
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper)
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper, DEFAULT_OPTS)
|
|
|
|
|
should(home.albums.length).eql(1)
|
|
|
|
|
should(home.albums[0].title).eql('one')
|
|
|
|
|
should(home.albums[0].albums.length).eql(1)
|
|
|
|
@ -96,7 +104,7 @@ describe('hierarchy', function () {
|
|
|
|
|
fixtures.photo({ path: 'one/two/IMG_000002.jpg' })
|
|
|
|
|
]
|
|
|
|
|
const mapper = mockMapper(file => [path.dirname(file.path)])
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper)
|
|
|
|
|
const home = hierarchy.createAlbums(files, mapper, DEFAULT_OPTS)
|
|
|
|
|
should(home.albums.length).eql(1)
|
|
|
|
|
should(home.albums[0].title).eql('one')
|
|
|
|
|
should(home.albums[0].files).eql([files[0]])
|
|
|
|
|