Skip to content

Commit

Permalink
Moved unit tests to the correct spot.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Jan 21, 2025
1 parent 0f54b59 commit 251f238
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 35 deletions.
35 changes: 0 additions & 35 deletions tests/magick-image/statistics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,6 @@ describe('MagickImage#statistics', () => {
});
});

it('should return the statistics for a channel', () => {
TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => {
const statistics = image.statistics(Channels.Blue);

let channelStatistics = statistics.getChannel(PixelChannel.Blue);
channelStatistics = expectToNotBeNull(channelStatistics);
expect(channelStatistics.channel).toBe(PixelChannel.Blue);
expect(channelStatistics.depth).toBe(8);
expect(channelStatistics.entropy).toBeCloseTo(0.80694, 4);
expect(channelStatistics.kurtosis).toBeCloseTo(-0.27825, 4);
expect(channelStatistics.maximum).toBe(255);
expect(channelStatistics.mean).toBeCloseTo(130.64240, 4);
expect(channelStatistics.minimum).toBe(2);
expect(channelStatistics.skewness).toBeCloseTo(-1.00552, 4);
expect(channelStatistics.standardDeviation).toBeCloseTo(42.70252, 4);
});
});

it('should return the statistics for the composite channel', () => {
TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => {
const statistics = image.statistics(Channels.Green);

const channelStatistics = statistics.composite();
expect(channelStatistics.channel).toBe(PixelChannel.Composite);
expect(channelStatistics.depth).toBe(8);
expect(channelStatistics.entropy).toBeCloseTo(0.76887, 4);
expect(channelStatistics.kurtosis).toBeCloseTo(0.65771, 4);
expect(channelStatistics.maximum).toBe(255);
expect(channelStatistics.mean).toBeCloseTo(100.22261, 4);
expect(channelStatistics.minimum).toBe(1);
expect(channelStatistics.skewness).toBeCloseTo(-0.65869, 4);
expect(channelStatistics.standardDeviation).toBeCloseTo(32.03352, 4);
});
});

it('should return null as the statistics for a unknown channel', () => {
TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => {
const statistics = image.statistics(Channels.Red);
Expand Down
27 changes: 27 additions & 0 deletions tests/statistics/statistics/composite.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm.
Licensed under the Apache License, Version 2.0.
*/

import { Channels } from '@src/enums/channels';
import { PixelChannel } from '@src/enums/pixel-channel';
import { TestFiles } from '@test/test-files';

describe('Statistics#composite', () => {
it('should return the statistics for the composite channel', () => {
TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => {
const statistics = image.statistics(Channels.Green);

const channelStatistics = statistics.composite();
expect(channelStatistics.channel).toBe(PixelChannel.Composite);
expect(channelStatistics.depth).toBe(8);
expect(channelStatistics.entropy).toBeCloseTo(0.76887, 4);
expect(channelStatistics.kurtosis).toBeCloseTo(0.65771, 4);
expect(channelStatistics.maximum).toBe(255);
expect(channelStatistics.mean).toBeCloseTo(100.22261, 4);
expect(channelStatistics.minimum).toBe(1);
expect(channelStatistics.skewness).toBeCloseTo(-0.65869, 4);
expect(channelStatistics.standardDeviation).toBeCloseTo(32.03352, 4);
});
});
});
28 changes: 28 additions & 0 deletions tests/statistics/statistics/get-channel.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm.
Licensed under the Apache License, Version 2.0.
*/

import { Channels } from '@src/enums/channels';
import { PixelChannel } from '@src/enums/pixel-channel';
import { TestFiles } from '@test/test-files';

describe('Statistics#getChannel', () => {
it('should return the statistics for a channel', () => {
TestFiles.Images.fujiFilmFinePixS1ProJpg.use(image => {
const statistics = image.statistics(Channels.Blue);

let channelStatistics = statistics.getChannel(PixelChannel.Blue);
channelStatistics = expectToNotBeNull(channelStatistics);
expect(channelStatistics.channel).toBe(PixelChannel.Blue);
expect(channelStatistics.depth).toBe(8);
expect(channelStatistics.entropy).toBeCloseTo(0.80694, 4);
expect(channelStatistics.kurtosis).toBeCloseTo(-0.27825, 4);
expect(channelStatistics.maximum).toBe(255);
expect(channelStatistics.mean).toBeCloseTo(130.64240, 4);
expect(channelStatistics.minimum).toBe(2);
expect(channelStatistics.skewness).toBeCloseTo(-1.00552, 4);
expect(channelStatistics.standardDeviation).toBeCloseTo(42.70252, 4);
});
});
});

0 comments on commit 251f238

Please sign in to comment.