@@ -52,7 +52,6 @@ describe("cloudinary", function () {
52
52
$rootScope . testPublicId = 'barfoo' ;
53
53
$rootScope . $digest ( ) ;
54
54
expect ( element . html ( ) ) . toMatch ( "src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/barfoo\"" ) ;
55
-
56
55
} ) ;
57
56
} ) ;
58
57
describe ( "html-width" , function ( ) {
@@ -79,8 +78,65 @@ describe("cloudinary", function () {
79
78
expect ( element . html ( ) ) . toMatch ( "src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/barfoo\"" ) ;
80
79
81
80
} ) ;
81
+ } ) ;
82
+
83
+ describe ( 'conditional transformation' , function ( ) {
84
+ it ( 'should add if (condition) to the result URL' , function ( ) {
85
+ // Compile a piece of HTML containing the directive
86
+ var element = $compile ( "<div><cl-image public_id='foobar' if='w_gt_200' width='100' crop='scale'/></div>" ) ( $rootScope ) ;
87
+ // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
88
+ $rootScope . $digest ( ) ;
89
+
90
+ // Check that the compiled element contains the templated content
91
+ expect ( element . html ( ) ) . toMatch ( "src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/if_w_gt_200,c_scale,w_100/foobar\"" ) ;
92
+ } ) ;
93
+
94
+ it ( 'should add if (condition) to the result URL' , function ( ) {
95
+ // Compile a piece of HTML containing the directive
96
+ var element = $compile ( "<div><cl-image public_id='foobar'><cl-transformation if='w_gt_200' width='100' crop='scale'/></cl-image></div>" ) ( $rootScope ) ;
97
+ // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
98
+ $rootScope . $digest ( ) ;
99
+
100
+ // Check that the compiled element contains the templated content
101
+ expect ( element . html ( ) ) . toMatch ( "src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/if_w_gt_200,c_scale,w_100/foobar\"" ) ;
102
+ } ) ;
103
+
104
+ it ( 'should add if (condition) to the result URL' , function ( ) {
105
+ // Compile a piece of HTML containing the directive
106
+ var element = $compile ( "<div>" +
107
+ "<cl-image public_id='foobar'>" +
108
+ "<cl-transformation if='w_gt_200'/>" +
109
+ "<cl-transformation width='100' crop='scale'/>" +
110
+ "<cl-transformation height='100' crop='fill'/>" +
111
+ "<cl-transformation if='end'/>" +
112
+ "</cl-image></div>" ) ( $rootScope ) ;
113
+ // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
114
+ $rootScope . $digest ( ) ;
115
+
116
+ // Check that the compiled element contains the templated content
117
+ expect ( element . html ( ) ) . toMatch ( "src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/if_w_gt_200/c_scale,w_100/c_fill,h_100/if_end/foobar\"" ) ;
118
+ } ) ;
119
+
120
+ it ( 'should add if (condition) to the result URL' , function ( ) {
121
+ // Compile a piece of HTML containing the directive
122
+ var element = $compile ( "<div>" +
123
+ "<cl-image public_id='foobar'>" +
124
+ "<cl-transformation if='w_gt_200'/>" +
125
+ "<cl-transformation width='100' crop='scale'/>" +
126
+ "<cl-transformation height='100' crop='fill'/>" +
127
+ "<cl-transformation if='else'/>" +
128
+ "<cl-transformation width='200' crop='fill'/>" +
129
+ "<cl-transformation height='200' crop='fit'/>" +
130
+ "<cl-transformation if='end'/>" +
131
+ "</cl-image></div>" ) ( $rootScope ) ;
132
+ // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
133
+ $rootScope . $digest ( ) ;
82
134
135
+ // Check that the compiled element contains the templated content
136
+ expect ( element . html ( ) ) . toMatch ( "src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/if_w_gt_200/c_scale,w_100/c_fill,h_100/if_else/c_fill,w_200/c_fit,h_200/if_end/foobar\"" ) ;
137
+ } ) ;
83
138
} ) ;
139
+
84
140
describe ( "responsive" , function ( ) {
85
141
var testWindow , tabImage2 , image1 ;
86
142
beforeAll ( function ( done ) {
0 commit comments