next-cloudinary 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,112 +0,0 @@
1
- import { Cloudinary } from '@cloudinary/url-gen';
2
-
3
- import * as overlaysPlugin from '../../src/plugins/overlays';
4
-
5
- const { plugin, DEFAULT_TEXT_OPTIONS } = overlaysPlugin
6
-
7
- const cld = new Cloudinary({
8
- cloud: {
9
- cloudName: 'test-cloud-name'
10
- }
11
- });
12
-
13
- const TEST_PUBLIC_ID = 'test-public-id';
14
-
15
- describe('Plugins', () => {
16
- describe('Text Overlays', () => {
17
- it('should add a text overlay configured by overlay object', () => {
18
- const cldImage = cld.image(TEST_PUBLIC_ID);
19
-
20
- const color = 'white';
21
- const fontFamily = 'Source Sans Pro';
22
- const fontSize = 200;
23
- const fontWeight = 'bold';
24
- const text = 'Next Cloudinary';
25
-
26
- const options = {
27
- overlays: [{
28
- text: {
29
- color,
30
- fontFamily,
31
- fontSize,
32
- fontWeight,
33
- text
34
- }
35
- }]
36
- }
37
-
38
- plugin({
39
- cldImage,
40
- options
41
- });
42
-
43
-
44
- expect(cldImage.toURL()).toContain(`l_text:${encodeURIComponent(fontFamily)}_${fontSize}_${fontWeight}:${encodeURIComponent(text)},co_${color}/fl_layer_apply,fl_no_overflow/${TEST_PUBLIC_ID}`);
45
- });
46
-
47
- it('should add a text overlay by overlay object text string', () => {
48
- const cldImage = cld.image(TEST_PUBLIC_ID);
49
-
50
- const { color, fontFamily, fontSize, fontWeight } = DEFAULT_TEXT_OPTIONS;
51
- const text = 'Next Cloudinary';
52
-
53
- const options = {
54
- overlays: [{
55
- text
56
- }]
57
- }
58
-
59
- plugin({
60
- cldImage,
61
- options
62
- });
63
-
64
- expect(cldImage.toURL()).toContain(`l_text:${encodeURIComponent(fontFamily)}_${fontSize}_${fontWeight}:${encodeURIComponent(text)},co_${color}/fl_layer_apply,fl_no_overflow/${TEST_PUBLIC_ID}`);
65
- });
66
-
67
- it('should add a text overlay by text string', () => {
68
- const cldImage = cld.image(TEST_PUBLIC_ID);
69
-
70
- const { color, fontFamily, fontSize, fontWeight } = DEFAULT_TEXT_OPTIONS;
71
- const text = 'Next Cloudinary';
72
-
73
- const options = {
74
- text
75
- }
76
-
77
- plugin({
78
- cldImage,
79
- options
80
- });
81
-
82
- expect(cldImage.toURL()).toContain(`l_text:${encodeURIComponent(fontFamily)}_${fontSize}_${fontWeight}:${encodeURIComponent(text)},co_${color}/fl_layer_apply,fl_no_overflow/${TEST_PUBLIC_ID}`);
83
- });
84
-
85
- it('should add a text overlay by text object', () => {
86
- const cldImage = cld.image(TEST_PUBLIC_ID);
87
-
88
- const color = 'white';
89
- const fontFamily = 'Source Sans Pro';
90
- const fontSize = 200;
91
- const fontWeight = 'bold';
92
- const text = 'Next Cloudinary';
93
-
94
- const options = {
95
- text: {
96
- color,
97
- fontFamily,
98
- fontSize,
99
- fontWeight,
100
- text
101
- }
102
- }
103
-
104
- plugin({
105
- cldImage,
106
- options
107
- });
108
-
109
- expect(cldImage.toURL()).toContain(`l_text:${encodeURIComponent(fontFamily)}_${fontSize}_${fontWeight}:${encodeURIComponent(text)},co_${color}/fl_layer_apply,fl_no_overflow/${TEST_PUBLIC_ID}`);
110
- });
111
- });
112
- });
@@ -1,54 +0,0 @@
1
- import { Cloudinary } from '@cloudinary/url-gen';
2
-
3
- import * as rawTransformationsPlugin from '../../src/plugins/raw-transformations';
4
-
5
- const { plugin } = rawTransformationsPlugin
6
-
7
- const cld = new Cloudinary({
8
- cloud: {
9
- cloudName: 'test-cloud-name'
10
- }
11
- });
12
-
13
- const TEST_PUBLIC_ID = 'test-public-id';
14
-
15
- describe('Plugins', () => {
16
- describe('Raw Transformations', () => {
17
- it('should apply a single raw transformations to the end of a Cloudinary URL', () => {
18
-
19
- const cldImage = cld.image(TEST_PUBLIC_ID);
20
-
21
- const options = {
22
- rawTransformations: [
23
- 'e_blur:2000'
24
- ]
25
- }
26
-
27
- plugin({
28
- cldImage,
29
- options
30
- });
31
-
32
- expect(cldImage.toURL()).toContain(`${options.rawTransformations.join('/')}/${TEST_PUBLIC_ID}`);
33
- });
34
-
35
- it('should apply an array of raw transformations to the end of a Cloudinary URL', () => {
36
-
37
- const cldImage = cld.image(TEST_PUBLIC_ID);
38
-
39
- const options = {
40
- rawTransformations: [
41
- 'e_blur:2000',
42
- 'e_tint:100:0000FF:0p:FF1493:100p'
43
- ]
44
- }
45
-
46
- plugin({
47
- cldImage,
48
- options
49
- });
50
-
51
- expect(cldImage.toURL()).toContain(`${options.rawTransformations.join('/')}/${TEST_PUBLIC_ID}`);
52
- })
53
- });
54
- });
@@ -1,62 +0,0 @@
1
- import { Cloudinary } from '@cloudinary/url-gen';
2
-
3
- import * as underlaysPlugin from '../../src/plugins/underlays';
4
-
5
- const { plugin, DEFAULT_TEXT_OPTIONS } = underlaysPlugin
6
-
7
- const cld = new Cloudinary({
8
- cloud: {
9
- cloudName: 'test-cloud-name'
10
- }
11
- });
12
-
13
- const TEST_PUBLIC_ID = 'test-public-id';
14
-
15
- describe('Plugins', () => {
16
- describe('Underlays', () => {
17
- it('should add an underlay configured by object', () => {
18
- const cldImage = cld.image(TEST_PUBLIC_ID);
19
-
20
- const publicId = 'images/galaxy';
21
- const width = 1920;
22
- const height = 1200;
23
- const crop = 'fill';
24
-
25
- const options = {
26
- underlays: [{
27
- publicId,
28
- width,
29
- height,
30
- crop,
31
- }]
32
- }
33
-
34
- plugin({
35
- cldImage,
36
- options
37
- });
38
-
39
- expect(cldImage.toURL()).toContain(`u_${publicId.replace(/\//g, ':')},w_${width},h_${height},c_${crop}/fl_layer_apply,fl_no_overflow/${TEST_PUBLIC_ID}`);
40
- });
41
-
42
- it('should add an underlay by string', () => {
43
- const cldImage = cld.image(TEST_PUBLIC_ID);
44
-
45
- const publicId = 'images/galaxy';
46
- const width = 1920;
47
- const height = 1200;
48
- const crop = 'fill';
49
-
50
- const options = {
51
- underlay: publicId
52
- }
53
-
54
- plugin({
55
- cldImage,
56
- options
57
- });
58
-
59
- expect(cldImage.toURL()).toContain(`u_${publicId.replace(/\//g, ':')},c_${crop}/fl_layer_apply,fl_no_overflow/${TEST_PUBLIC_ID}`);
60
- });
61
- });
62
- });