Skip to content

Commit

Permalink
Fixed unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Aug 5, 2024
1 parent c1ae2c1 commit 64b2d90
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions tests/settings/connected-components-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Licensed under the Apache License, Version 2.0.
*/

import { TemporaryDefines } from '@src/helpers/temporary-defines';
import { ConnectedComponentsSettings } from '@src/settings/connected-components-settings';
import { Threshold } from '@src/types/threshold';
import { TestImages } from '@test/test-images';
Expand All @@ -23,30 +24,20 @@ describe('ConnectedComponentsSettings', () => {
describe('#_addArtifacts', () => {
it('should add all defined artifacts to the provided image', () => {
TestImages.Builtin.logo.use((image) => {
settings._setArtifacts(image);
TemporaryDefines.use(image, (temporaryDefines) => {
settings._setArtifacts(temporaryDefines);

expect(image.artifactNames.length).toBe(9);
expect(image.getArtifact('connected-components:angle-threshold')).toBe('10');
expect(image.getArtifact('connected-components:area-threshold')).toBe('20');
expect(image.getArtifact('connected-components:circularity-threshold')).toBe('30');
expect(image.getArtifact('connected-components:diameter-threshold')).toBe('40');
expect(image.getArtifact('connected-components:eccentricity-threshold')).toBe('50');
expect(image.getArtifact('connected-components:major-axis-threshold')).toBe('60');
expect(image.getArtifact('connected-components:mean-color')).toBe('true');
expect(image.getArtifact('connected-components:minor-axis-threshold')).toBe('70');
expect(image.getArtifact('connected-components:perimeter-threshold')).toBe('80');
});
});
});

describe('#_removeArtifacts', () => {
it('should remove all undefined artifacts from the provided image', () => {
TestImages.Builtin.logo.use((image) => {
settings._setArtifacts(image);
expect(image.artifactNames.length).toBe(9);

settings._removeArtifacts(image);
expect(image.artifactNames.length).toBe(0);
expect(image.artifactNames.length).toBe(9);
expect(image.getArtifact('connected-components:angle-threshold')).toBe('10');
expect(image.getArtifact('connected-components:area-threshold')).toBe('20');
expect(image.getArtifact('connected-components:circularity-threshold')).toBe('30');
expect(image.getArtifact('connected-components:diameter-threshold')).toBe('40');
expect(image.getArtifact('connected-components:eccentricity-threshold')).toBe('50');
expect(image.getArtifact('connected-components:major-axis-threshold')).toBe('60');
expect(image.getArtifact('connected-components:mean-color')).toBe('true');
expect(image.getArtifact('connected-components:minor-axis-threshold')).toBe('70');
expect(image.getArtifact('connected-components:perimeter-threshold')).toBe('80');
});
});
});
});
Expand Down

0 comments on commit 64b2d90

Please sign in to comment.