1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/test/backend/unit/model/threading/MetaDataLoader.spec.ts

55 lines
2.5 KiB
TypeScript
Raw Normal View History

2018-12-20 23:02:49 +01:00
import {expect} from 'chai';
2019-12-10 10:44:35 +01:00
import {MetadataLoader} from '../../../../../src/backend/model/threading/MetadataLoader';
import {Utils} from '../../../../../src/common/Utils';
2018-12-20 23:02:49 +01:00
import * as path from 'path';
describe('MetadataLoader', () => {
it('should load png', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/test_png.png'));
2018-12-22 01:14:13 +01:00
delete data.creationDate; // creation time for png not supported
2020-09-13 14:43:03 +02:00
const expected = require(path.join(__dirname, '/../../../assets/test_png.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
2018-12-20 23:02:49 +01:00
});
it('should load jpg', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json'));
2019-01-13 17:38:39 +01:00
expect(Utils.clone(data)).to.be.deep.equal(expected);
2018-12-20 23:02:49 +01:00
});
2020-02-08 16:31:29 +01:00
it('should load miss dated jpg', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/date_issue.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/date_issue.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
2019-01-19 10:07:06 +01:00
it('should load jpg 2', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/old_photo.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/old_photo.json'));
2019-01-19 10:07:06 +01:00
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
2019-02-15 16:19:30 -05:00
it('should load jpg edited with exiftool', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/exiftool.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/exiftool.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
2019-02-15 16:19:30 -05:00
it('should load mp4', async () => {
const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/video.mp4'));
const expected = require(path.join(__dirname, '/../../../assets/video.json'));
2019-02-15 16:19:30 -05:00
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should respect mp4 rotate transformation', async () => {
const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/video_rotate.mp4'));
const expected = require(path.join(__dirname, '/../../../assets/video_rotate.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
2019-02-15 16:19:30 -05:00
2018-12-20 23:02:49 +01:00
});