1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/test/backend/unit/model/fileprocessing/PhotoProcessing.spec.ts

61 lines
1.9 KiB
TypeScript
Raw Normal View History

2019-12-27 04:03:10 +08: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 23:54:21 +08:00
import {PhotoProcessing} from '../../../../../src/backend/model/fileaccess/fileprocessing/PhotoProcessing';
2019-12-27 04:03:10 +08:00
describe('PhotoProcessing', () => {
2023-11-27 05:47:57 +08:00
it('should generate converted gif file path', async () => {
await Config.load();
Config.Media.Photo.thumbnailSizes = [];
2023-11-27 05:47:57 +08: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-27 05:47:57 +08:00
});
2022-04-05 01:37:31 +08:00
/* eslint-disable no-unused-expressions,@typescript-eslint/no-unused-expressions */
2019-12-27 04:03:10 +08:00
it('should generate converted thumbnail path', async () => {
2023-09-21 03:37:33 +08:00
await Config.load();
Config.Media.Photo.thumbnailSizes = [10, 20];
ProjectPath.ImageFolder = path.join(__dirname, './../../../assets');
2019-12-27 04:03:10 +08:00
const photoPath = path.join(ProjectPath.ImageFolder, 'test_png.png');
for (const thSize of Config.Media.Photo.thumbnailSizes) {
2019-12-27 04:03:10 +08:00
expect(await PhotoProcessing
2019-12-29 07:35:41 +08:00
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(photoPath, thSize)))
2019-12-27 04:03:10 +08:00
.to.be.true;
expect(await PhotoProcessing
2019-12-29 07:35:41 +08:00
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(photoPath + 'noPath', thSize)))
2019-12-27 04:03:10 +08:00
.to.be.false;
}
expect(await PhotoProcessing
2019-12-29 07:35:41 +08:00
.isValidConvertedPath(PhotoProcessing.generateConvertedPath(photoPath, 30)))
2019-12-27 04:03:10 +08:00
.to.be.false;
});
});