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

61 lines
1.9 KiB
TypeScript
Raw Normal View History

2019-12-26 21:03:10 +01:00
import {expect} from 'chai';
import {Config} from '../../../../../src/common/config/private/Config';
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
import * as path from 'path';
2023-10-14 17:54:21 +02:00
import {PhotoProcessing} from '../../../../../src/backend/model/fileaccess/fileprocessing/PhotoProcessing';
2019-12-26 21:03:10 +01:00
describe('PhotoProcessing', () => {
2023-11-26 22:47:57 +01:00
it('should generate converted gif file path', async () => {
await Config.load();
Config.Media.Photo.thumbnailSizes = [];
2023-11-26 22:47:57 +01:00
ProjectPath.ImageFolder = path.join(__dirname, './../../../assets');
const gifPath = path.join(ProjectPath.ImageFolder, 'earth.gif');
for (const thSize of Config.Media.Photo.thumbnailSizes) {
Config.Media.Photo.animateGif = true;
expect(await PhotoProcessing
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(gifPath, thSize)))
.to.be.true;
Config.Media.Photo.animateGif = false;
expect(await PhotoProcessing
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(gifPath, thSize)))
.to.be.true;
}
2023-11-26 22:47:57 +01:00
});
2022-04-04 19:37:31 +02:00
/* eslint-disable no-unused-expressions,@typescript-eslint/no-unused-expressions */
2019-12-26 21:03:10 +01:00
it('should generate converted thumbnail path', async () => {
2023-09-20 21:37:33 +02:00
await Config.load();
Config.Media.Photo.thumbnailSizes = [10, 20];
ProjectPath.ImageFolder = path.join(__dirname, './../../../assets');
2019-12-26 21:03:10 +01:00
const photoPath = path.join(ProjectPath.ImageFolder, 'test_png.png');
for (const thSize of Config.Media.Photo.thumbnailSizes) {
2019-12-26 21:03:10 +01:00
expect(await PhotoProcessing
2019-12-29 00:35:41 +01:00
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(photoPath, thSize)))
2019-12-26 21:03:10 +01:00
.to.be.true;
expect(await PhotoProcessing
2019-12-29 00:35:41 +01:00
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(photoPath + 'noPath', thSize)))
2019-12-26 21:03:10 +01:00
.to.be.false;
}
expect(await PhotoProcessing
2019-12-29 00:35:41 +01:00
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(photoPath, 30)))
2019-12-26 21:03:10 +01:00
.to.be.false;
});
});