Skip to content

Commit 05d3621

Browse files
author
Nir Maoz
authored
Refactor fromJson tests (#468)
1 parent 0421b35 commit 05d3621

File tree

3 files changed

+44
-38
lines changed

3 files changed

+44
-38
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {fromJson} from "../../../src/internal/fromJson";
2+
3+
describe('delivery.fromJson', () => {
4+
it('should generate a transformation string from colorSpace action', function () {
5+
const transformation = fromJson([
6+
{actionType: 'colorSpace', mode: 'srgbTrueColor'}
7+
]);
8+
9+
expect(transformation.toString()).toStrictEqual('cs_srgb:truecolor');
10+
});
11+
});

__TESTS__/unit/fromJson/fromJson.test.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,6 @@ import {fromJson} from "../../../src/internal/fromJson";
22
import {createUnsupportedError} from "../../../src/internal/utils/unsupportedError";
33

44
describe('fromJson', () => {
5-
it('should generate a url with resize actions from array of models', function () {
6-
const transformation = fromJson([
7-
{actionType: 'scale', dimensions: {width: 100, aspectRatio: 7}},
8-
{actionType: 'fit', dimensions: {height: 200, aspectRatio: '16:9'}, relative: true},
9-
{actionType: 'limitFit', dimensions: {height: 200, aspectRatio: 'ignore_aspect_ratio'}, relative: true},
10-
{actionType: 'minimumFit', dimensions: {width: 100}, regionRelative: true},
11-
{actionType: 'crop', dimensions: {width: 100}, regionRelative: true, gravity: 'north_east', y: 3, zoom: 7},
12-
{actionType: 'fill', dimensions: {width: 100}, relative: true, gravity: 'south', x: 4, y: 5},
13-
{actionType: 'limitFill', dimensions: {width: 100}, relative: true, gravity: 'south', x: 4, y: 5},
14-
{actionType: 'thumbnail', dimensions: {width: 100}, relative: true, gravity: 'south', zoom: 4},
15-
{actionType: 'pad', dimensions: {width: 100}, relative: true, gravity: 'south', x: 3, y:4, background: 'white'},
16-
{actionType: 'limitPad', dimensions: {width: 100}, relative: true, gravity: 'south', x: 3, y:4, background: 'white'},
17-
{actionType: 'minimumPad', dimensions: {width: 100}, relative: true, gravity: 'south', x: 3, y:4, background: 'white'},
18-
]);
19-
20-
expect(transformation.toString()).toStrictEqual([
21-
'ar_7.0,c_scale,w_100',
22-
'ar_16:9,c_fit,fl_relative,h_200',
23-
'c_limit,fl_ignore_aspect_ratio,fl_relative,h_200',
24-
'c_mfit,fl_region_relative,w_100',
25-
'c_crop,fl_region_relative,g_north_east,w_100,y_3,z_7',
26-
'c_fill,fl_relative,g_south,w_100,x_4,y_5',
27-
'c_lfill,fl_relative,g_south,w_100,x_4,y_5',
28-
'c_thumb,fl_relative,g_south,w_100,z_4',
29-
'b_white,c_pad,fl_relative,g_south,w_100,x_3,y_4',
30-
'b_white,c_lpad,fl_relative,g_south,w_100,x_3,y_4',
31-
'b_white,c_mpad,fl_relative,g_south,w_100,x_3,y_4',
32-
].join('/'));
33-
});
34-
35-
it('should generate a transformation string from colorSpace action', function () {
36-
const transformation = fromJson([
37-
{actionType: 'colorSpace', mode: 'srgbTrueColor'}
38-
]);
39-
40-
expect(transformation.toString()).toStrictEqual('cs_srgb:truecolor');
41-
});
42-
435
it('should generate an error for array that includes an unsupported action', function () {
446
const transformation = fromJson([
457
{actionType: 'unsupported', dimensions: {width: 100}},
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {fromJson} from "../../../src/internal/fromJson";
2+
3+
describe('resize.fromJson', () => {
4+
it('should generate a url with resize actions from array of models', function () {
5+
const transformation = fromJson([
6+
{actionType: 'scale', dimensions: {width: 100, aspectRatio: 7}},
7+
{actionType: 'fit', dimensions: {height: 200, aspectRatio: '16:9'}, relative: true},
8+
{actionType: 'limitFit', dimensions: {height: 200, aspectRatio: 'ignore_aspect_ratio'}, relative: true},
9+
{actionType: 'minimumFit', dimensions: {width: 100}, regionRelative: true},
10+
{actionType: 'crop', dimensions: {width: 100}, regionRelative: true, gravity: 'north_east', y: 3, zoom: 7},
11+
{actionType: 'fill', dimensions: {width: 100}, relative: true, gravity: 'south', x: 4, y: 5},
12+
{actionType: 'limitFill', dimensions: {width: 100}, relative: true, gravity: 'south', x: 4, y: 5},
13+
{actionType: 'thumbnail', dimensions: {width: 100}, relative: true, gravity: 'south', zoom: 4},
14+
{actionType: 'pad', dimensions: {width: 100}, relative: true, gravity: 'south', x: 3, y:4, background: 'white'},
15+
{actionType: 'limitPad', dimensions: {width: 100}, relative: true, gravity: 'south', x: 3, y:4, background: 'white'},
16+
{actionType: 'minimumPad', dimensions: {width: 100}, relative: true, gravity: 'south', x: 3, y:4, background: 'white'},
17+
]);
18+
19+
expect(transformation.toString()).toStrictEqual([
20+
'ar_7.0,c_scale,w_100',
21+
'ar_16:9,c_fit,fl_relative,h_200',
22+
'c_limit,fl_ignore_aspect_ratio,fl_relative,h_200',
23+
'c_mfit,fl_region_relative,w_100',
24+
'c_crop,fl_region_relative,g_north_east,w_100,y_3,z_7',
25+
'c_fill,fl_relative,g_south,w_100,x_4,y_5',
26+
'c_lfill,fl_relative,g_south,w_100,x_4,y_5',
27+
'c_thumb,fl_relative,g_south,w_100,z_4',
28+
'b_white,c_pad,fl_relative,g_south,w_100,x_3,y_4',
29+
'b_white,c_lpad,fl_relative,g_south,w_100,x_3,y_4',
30+
'b_white,c_mpad,fl_relative,g_south,w_100,x_3,y_4',
31+
].join('/'));
32+
});
33+
});

0 commit comments

Comments
 (0)