Skip to content

Commit d8ded49

Browse files
committed
added tests for unsharp mask from/toJson
1 parent 7ebbeb7 commit d8ded49

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

__TESTS__/unit/fromJson/adjust.fromJson.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import {fromJson} from "../../../src/internal/fromJson";
33
describe('adjust.fromJson', () => {
44
it('should generate a url with adjust actions from array of models', function () {
55
const transformation = fromJson([
6-
{ actionType: 'improve', mode: 'outdoor', blend: 30}
6+
{ actionType: 'improve', mode: 'outdoor', blend: 30},
7+
{ actionType: 'unsharpMask', level: 50}
78
]);
89

910
expect(transformation.toString()).toStrictEqual([
1011
'e_improve:outdoor:30',
12+
'e_unsharp_mask:50'
1113
].join('/'));
1214
});
1315
});

__TESTS__/unit/toJson/adjust.toJson.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,15 @@ describe('Adjust toJson()', () => {
1313
}
1414
]);
1515
});
16+
17+
it('unsharpMask.improve', () => {
18+
const transformation = new Transformation()
19+
.addAction(Adjust.unsharpMask().strength(10));
20+
expect(transformation.toJson()).toStrictEqual( [
21+
{
22+
actionType: 'unsharpMask',
23+
level: 10
24+
}
25+
]);
26+
});
1627
});

src/internal/fromJson.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ const ActionModelMap: Record<string, IHasFromJson> = {
8383
deshake: DeshakeEffectAction,
8484
pixelate: Pixelate,
8585
blur: BlurAction,
86-
improve: ImproveAction
86+
improve: ImproveAction,
87+
unsharpMask: EffectActionWithStrength
8788
};
8889

8990
/**

src/internal/internalConstants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export const ACTION_TYPE_TO_DELIVERY_MODE_MAP: Record<string, string> = {
104104
export const ACTION_TYPE_TO_EFFECT_MODE_MAP: Record<string, string> = {
105105
redEye: 'redeye',
106106
advancedRedEye: 'adv_redeye',
107-
oilPaint: 'oil_paint'
107+
oilPaint: 'oil_paint',
108+
unsharpMask: 'unsharp_mask'
108109
};
109110

110111
export const CHROMA_VALUE_TO_CHROMA_MODEL_ENUM: Record<number, string> = {

0 commit comments

Comments
 (0)