Skip to content

Commit bf95451

Browse files
authored
Fix fromJson for quality action (#492)
1 parent 250bb9f commit bf95451

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

__TESTS__/unit/fromJson/delivery.fromJson.test.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,72 @@ describe('delivery.fromJson', () => {
9090
expect(transformation.toString()).toStrictEqual('q_auto:best');
9191
});
9292

93+
it('quality:auto:eco', () => {
94+
const transformation = fromJson([
95+
{
96+
actionType: 'quality',
97+
level: 'autoEco'
98+
}
99+
]);
100+
101+
expect(transformation.toString()).toStrictEqual('q_auto:eco');
102+
});
103+
104+
it('quality:auto:good', () => {
105+
const transformation = fromJson([
106+
{
107+
actionType: 'quality',
108+
level: 'autoGood'
109+
}
110+
]);
111+
112+
expect(transformation.toString()).toStrictEqual('q_auto:good');
113+
});
114+
115+
it('quality:auto:low', () => {
116+
const transformation = fromJson([
117+
{
118+
actionType: 'quality',
119+
level: 'autoLow'
120+
}
121+
]);
122+
123+
expect(transformation.toString()).toStrictEqual('q_auto:low');
124+
});
125+
126+
it('quality:jpegminiHigh', () => {
127+
const transformation = fromJson([
128+
{
129+
actionType: 'quality',
130+
level: 'jpegminiHigh'
131+
}
132+
]);
133+
134+
expect(transformation.toString()).toStrictEqual('q_jpegmini:1');
135+
});
136+
137+
it('quality:jpegminiMedium', () => {
138+
const transformation = fromJson([
139+
{
140+
actionType: 'quality',
141+
level: 'jpegminiMedium'
142+
}
143+
]);
144+
145+
expect(transformation.toString()).toStrictEqual('q_jpegmini:2');
146+
});
147+
148+
it('quality:jpegminiBest', () => {
149+
const transformation = fromJson([
150+
{
151+
actionType: 'quality',
152+
level: 'jpegminiBest'
153+
}
154+
]);
155+
156+
expect(transformation.toString()).toStrictEqual('q_jpegmini:0');
157+
});
158+
93159
it('chromaSubSampling', () => {
94160
const transformation = fromJson([
95161
{

src/internal/internalConstants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export const ACTION_TYPE_TO_EFFECT_MODE_MAP: Record<string, string> = {
110110

111111
export const ACTION_TYPE_TO_QUALITY_MODE_MAP: Record<string, string> = {
112112
autoBest: 'auto:best',
113+
autoEco: 'auto:eco',
114+
autoGood: 'auto:good',
115+
autoLow: 'auto:low',
116+
jpegminiHigh: 'jpegmini:1',
117+
jpegminiMedium: 'jpegmini:2',
118+
jpegminiBest: 'jpegmini:0'
113119
};
114120

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

0 commit comments

Comments
 (0)