2018-03-31 03:30:30 +08:00
|
|
|
import {expect} from 'chai';
|
|
|
|
import {DiskMangerWorker} from '../../../../../backend/model/threading/DiskMangerWorker';
|
|
|
|
import * as path from 'path';
|
|
|
|
import {Config} from '../../../../../common/config/private/Config';
|
|
|
|
import {ProjectPath} from '../../../../../backend/ProjectPath';
|
2018-11-05 02:28:32 +08:00
|
|
|
import {PhotoDTO} from '../../../../../common/entities/PhotoDTO';
|
2017-07-16 03:04:41 +08:00
|
|
|
|
|
|
|
describe('DiskMangerWorker', () => {
|
|
|
|
|
2017-07-16 20:03:16 +08:00
|
|
|
it('should parse metadata', async () => {
|
2018-03-31 03:30:30 +08:00
|
|
|
Config.Server.imagesFolder = path.join(__dirname, '/../../assets');
|
|
|
|
ProjectPath.ImageFolder = path.join(__dirname, '/../../assets');
|
|
|
|
const dir = await DiskMangerWorker.scanDirectory('/');
|
2018-12-21 06:02:49 +08:00
|
|
|
expect(dir.media.length).to.be.equals(2);
|
2018-11-05 02:28:32 +08:00
|
|
|
expect(dir.media[0].name).to.be.equals('test image öüóőúéáű-.,.jpg');
|
2018-11-18 02:32:31 +08:00
|
|
|
expect((<PhotoDTO>dir.media[0]).metadata.keywords).to.deep.equals(['Berkley', 'USA', 'űáéúőóüö ŰÁÉÚŐÓÜÖ']);
|
2018-12-21 06:02:49 +08:00
|
|
|
expect(dir.media[0].metadata.fileSize).to.deep.equals(62786);
|
2018-11-05 02:28:32 +08:00
|
|
|
expect(dir.media[0].metadata.size).to.deep.equals({width: 140, height: 93});
|
|
|
|
expect((<PhotoDTO>dir.media[0]).metadata.cameraData).to.deep.equals({
|
2017-07-16 03:04:41 +08:00
|
|
|
ISO: 3200,
|
|
|
|
model: 'óüöúőűáé ÓÜÖÚŐŰÁÉ',
|
|
|
|
make: 'Canon',
|
|
|
|
fStop: 5.6,
|
|
|
|
exposure: 0.00125,
|
|
|
|
focalLength: 85,
|
|
|
|
lens: 'EF-S15-85mm f/3.5-5.6 IS USM'
|
|
|
|
});
|
|
|
|
|
2018-11-18 02:32:31 +08:00
|
|
|
expect((<PhotoDTO>dir.media[0]).metadata.positionData).to.deep.equals({
|
2017-07-16 03:04:41 +08:00
|
|
|
GPSData: {
|
|
|
|
latitude: 37.871093333333334,
|
|
|
|
longitude: -122.25678,
|
|
|
|
altitude: 102.4498997995992
|
|
|
|
},
|
2018-12-21 06:02:49 +08:00
|
|
|
country: 'mmóüöúőűáé ÓÜÖÚŐŰÁÉmm-.,|\\mm',
|
2017-07-16 20:03:16 +08:00
|
|
|
state: 'óüöúőűáé ÓÜÖÚŐŰÁ',
|
|
|
|
city: 'óüöúőűáé ÓÜÖÚŐŰÁ'
|
2017-07-16 03:04:41 +08:00
|
|
|
});
|
|
|
|
|
2018-11-05 02:28:32 +08:00
|
|
|
expect(dir.media[0].metadata.creationDate).to.be.equals(1434018566000);
|
2017-07-16 03:04:41 +08:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|