Skip to content

Commit

Permalink
test: Tests for PSD format
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor-pelykh committed May 10, 2024
1 parent 1293f07 commit 4838fe0
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 0 deletions.
Binary file added test/_input/psd/psd1.psd
Binary file not shown.
Binary file added test/_input/psd/psd2.psd
Binary file not shown.
Binary file added test/_input/psd/psd3.psd
Binary file not shown.
Binary file added test/_input/psd/psd4.psd
Binary file not shown.
Binary file added test/_input/psd/psd5.psd
Binary file not shown.
Binary file added test/_input/psd/psd6.psd
Binary file not shown.
1 change: 1 addition & 0 deletions test/_utils/test-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum TestSection {
jpeg,
png,
pnm,
psd,
tiff,
tga,
transform,
Expand Down
2 changes: 2 additions & 0 deletions test/_utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export abstract class TestUtils {
return 'png';
case TestSection.pnm:
return 'pnm';
case TestSection.psd:
return 'psd';
case TestSection.tiff:
return 'tiff';
case TestSection.tga:
Expand Down
38 changes: 38 additions & 0 deletions test/format/format.psd.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/** @format */

import { decodePsd, encodePng } from '../../src';
import { TestFolder } from '../_utils/test-folder';
import { TestSection } from '../_utils/test-section';
import { TestUtils } from '../_utils/test-utils';

describe('Format: PSD', () => {
const resFiles = TestUtils.listFiles(
TestFolder.input,
TestSection.psd,
'.psd'
);

for (const file of resFiles) {
test(file.nameExt, () => {
const input = TestUtils.readFromFilePath(file.path);
const psd = decodePsd({
data: input,
});

expect(psd).toBeDefined();
if (psd === undefined) {
return;
}

const png = encodePng({
image: psd,
});
TestUtils.writeToFile(
TestFolder.output,
TestSection.psd,
`${file.name}.png`,
png
);
});
}
});

0 comments on commit 4838fe0

Please sign in to comment.