Skip to content

Commit

Permalink
Moved unit tests to the correct file.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Aug 10, 2024
1 parent e741fba commit dcf8443
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
29 changes: 10 additions & 19 deletions tests/magick-image-collection/optimize-plus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,21 @@ describe('MagickImageCollection#optimizePlus', () => {
});

it('should add additional images', () => {
TestImages.emptyCollection.use((images) => {
TestImages.movingHoleGif.use((images) => {

images.push(MagickImage.create(MagickColors.Red, 1, 2));
images.push(MagickImage.create(MagickColors.Red, 1, 2));

const second = MagickImage.create(MagickColors.Red, 1, 1);
second.extent(1, 2, MagickColors.Green);
images.push(second);
expect(images.length).toBe(4);

images.optimizePlus();

expect(images.length).toBe(3);
expect(images[0].width).toBe(1);
expect(images[0].height).toBe(2);

expect(images[1].width).toBe(1);
expect(images[1].height).toBe(1);
expect(images[1].page.x).toBe(-1);
expect(images[1].page.y).toBe(-1);
expect(images.length).toBe(7);

expect(images[2].width).toBe(1);
expect(images[2].height).toBe(1);
expect(images[2].page.x).toBe(0);
expect(images[2].page.y).toBe(1);
expect(images[0].page.toString()).toBe('100x100+0+0');
expect(images[1].page.toString()).toBe('100x100+61+27');
expect(images[2].page.toString()).toBe('100x100+27+12');
expect(images[3].page.toString()).toBe('100x100+46+61');
expect(images[4].page.toString()).toBe('100x100+46+27');
expect(images[5].page.toString()).toBe('100x100+12+46');
expect(images[6].page.toString()).toBe('100x100+12+46');
});
});
});
31 changes: 20 additions & 11 deletions tests/magick-image-collection/optimize.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,30 @@ describe('MagickImageCollection#evaluate', () => {
});

it('should optimize the images', () => {
TestImages.movingHoleGif.use((images) => {
TestImages.emptyCollection.use((images) => {

images.push(MagickImage.create(MagickColors.Red, 1, 2));
images.push(MagickImage.create(MagickColors.Red, 1, 2));

const image = MagickImage.create(MagickColors.Red, 1, 1);
image.extent(1, 2, MagickColors.Green);
images.push(image);

expect(images.length).toBe(4);
images.optimize();

images.optimizePlus();
expect(images.length).toBe(3);
expect(images[0].width).toBe(1);
expect(images[0].height).toBe(2);

expect(images.length).toBe(7);
expect(images[1].width).toBe(1);
expect(images[1].height).toBe(1);
expect(images[1].page.x).toBe(-1);
expect(images[1].page.y).toBe(-1);

expect(images[0].page.toString()).toBe('100x100+0+0');
expect(images[1].page.toString()).toBe('100x100+61+27');
expect(images[2].page.toString()).toBe('100x100+27+12');
expect(images[3].page.toString()).toBe('100x100+46+61');
expect(images[4].page.toString()).toBe('100x100+46+27');
expect(images[5].page.toString()).toBe('100x100+12+46');
expect(images[6].page.toString()).toBe('100x100+12+46');
expect(images[2].width).toBe(1);
expect(images[2].height).toBe(1);
expect(images[2].page.x).toBe(0);
expect(images[2].page.y).toBe(1);
});
});
});

0 comments on commit dcf8443

Please sign in to comment.