Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js
sudo: false
node_js:
- '6'
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
install:
- npm install
- npm install bower
- bower install
cache:
directories:
- bower_components
- node_modules
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Cloudinary
==========
The official [Cloudinary](https://cloudinary.com) SDK for AngularJS (AKA Angular 1).

Cloudinary's Angular 2 SDK can be found [here](https://github.com/cloudinary/cloudinary_angular/tree/angular_next)
Cloudinary's Angular SDK can be found [here](https://github.com/cloudinary/cloudinary_angular)
and on [npm](https://www.npmjs.com/package/@cloudinary/angular)

Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline.
Expand Down
6 changes: 4 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
],
"dependencies": {
"angular": ">=1.3.10",
"cloudinary-core": "^2.0.4"
"cloudinary-core": "^2.0.4",
"bootstrap": "^3.3.7"
},
"repository": {
"type": "git",
Expand All @@ -43,6 +44,7 @@
"karma*"
],
"devDependencies": {
"angular-mocks": "^1.5.1"
"angular-mocks": "^1.5.1",
"bootstrap": "^3.3.7"
}
}
1 change: 1 addition & 0 deletions js/angular.cloudinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
return {
restrict : 'E',
transclude : false,
priority: 600,
require: '^clImage',
link : function (scope, element, attrs, clImageCtrl) {
clImageCtrl.addTransformation(toCloudinaryAttributes(attrs, /^[^$]/));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "karma start karma.conf.js"
},
"repository": {
"type": "git",
Expand Down
82 changes: 46 additions & 36 deletions spec/cloudinary_spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const CLOUD_NAME = "sdk-test";

const CLOUD_NAME = "sdk-test";
describe("cloudinary", function () {

var $compile,
$rootScope,
$window;
$rootScope,
$window;
beforeEach(function () {
module('cloudinary');
angular.module('cloudinary').config(['cloudinaryProvider', function (cloudinaryProvider) {
Expand Down Expand Up @@ -54,9 +53,9 @@ describe("cloudinary", function () {
expect(element.html()).toMatch("src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/barfoo\"");
});
});
describe("html-width", function(){
describe("html-width", function () {
var element;
beforeEach(function(){
beforeEach(function () {
$rootScope.testPublicId = "sample";
element = $compile("<div><cl-image public_id='{{testPublicId}}'/></div>")($rootScope);
$rootScope.$digest();
Expand All @@ -79,88 +78,99 @@ describe("cloudinary", function () {

});
});
describe ('conditional transformation', function(){
it ('should add if (condition) to the result URL', function() {

describe('conditional transformation', function () {
it('should add if (condition) to the result URL', function () {
// Compile a piece of HTML containing the directive
var element = $compile("<div><cl-image public_id='foobar' if='w_gt_200' width='100' crop='scale'/></div>")($rootScope);
$rootScope.$digest();

// Check that the compiled element contains the templated content
expect(element.html()).toMatch("src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/if_w_gt_200,c_scale,w_100/foobar\"");
});
it ('should add if (condition) to the result URL', function() {

it('should add if (condition) to the result URL', function () {
// Compile a piece of HTML containing the directive
var element = $compile("<div><cl-image public_id='foobar'><cl-transformation if='w_gt_200' width='100' crop='scale'/></cl-image></div>")($rootScope);
$rootScope.$digest();

// Check that the compiled element contains the templated content
expect(element.html()).toMatch("src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/if_w_gt_200,c_scale,w_100/foobar\"");
});
it ('should add if (condition) to the result URL', function() {
});

it('should add if (condition) to the result URL', function () {
// Compile a piece of HTML containing the directive
var element = $compile("<div>" +
"<cl-image public_id='foobar'>" +
"<cl-transformation if='w_gt_200'/>"+
"<cl-transformation width='100' crop='scale'/>" +
"<cl-transformation height='100' crop='fill'/>"+
"<cl-transformation if='end'/>" +
var element = $compile("<div>" +
"<cl-image public_id='foobar'>" +
"<cl-transformation if='w_gt_200'/>" +
"<cl-transformation width='100' crop='scale'/>" +
"<cl-transformation height='100' crop='fill'/>" +
"<cl-transformation if='end'/>" +
"</cl-image></div>")($rootScope);
$rootScope.$digest();

// Check that the compiled element contains the templated content
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\"");
});
it ('should add if (condition) to the result URL', function() {

it('should add if (condition) to the result URL', function () {
// Compile a piece of HTML containing the directive
var element = $compile("<div>" +
"<cl-image public_id='foobar'>" +
"<cl-transformation if='w_gt_200'/>"+
"<cl-transformation width='100' crop='scale'/>" +
"<cl-transformation height='100' crop='fill'/>"+
var element = $compile("<div>" +
"<cl-image public_id='foobar'>" +
"<cl-transformation if='w_gt_200'/>" +
"<cl-transformation width='100' crop='scale'/>" +
"<cl-transformation height='100' crop='fill'/>" +
"<cl-transformation if='else'/>" +
"<cl-transformation width='200' crop='fill'/>" +
"<cl-transformation height='200' crop='fit'/>"+
"<cl-transformation if='end'/>" +
"<cl-transformation width='200' crop='fill'/>" +
"<cl-transformation height='200' crop='fit'/>" +
"<cl-transformation if='end'/>" +
"</cl-image></div>")($rootScope);
$rootScope.$digest();

// Check that the compiled element contains the templated content
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\"");
});
});

describe("responsive", function () {
var testWindow, tabImage2, image1;
const isPhantomJS = /PhantomJS/.test(window.navigator.userAgent);
beforeAll(function (done) {
testWindow = window.open("/base/spec/responsive-core-test.html", "Cloudinary test #{(new Date()).toLocaleString()}", "width=200, height=500");

testWindow.addEventListener('load', function () {
image1 = testWindow.document.getElementById("image1");
tabImage2 = testWindow.document.getElementById("tabImage2");

expect(tabImage2).toBeDefined();
done();
});

setTimeout(done, 3000);

});
afterAll(function () {
testWindow && testWindow.close();
});
it('should enable responsive functionality', function () {
expect(tabImage2.getAttribute("src")).toMatch("https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/c_scale,w_200/sample.jpg");
it('should enable responsive functionality', function (done) {
if (!isPhantomJS) {
expect(tabImage2).toBeDefined();
expect(tabImage2.outerHTML).toMatch("src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/c_scale,w_200/sample.jpg\"");
}
done();
});
it("should react to a change in the parent's width", function (done) {

it("should react to a change in the parent's width", function (done) {
var listener = function () {
expect(tabImage2.outerHTML).toMatch("src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/c_scale,w_400/sample.jpg\"");
if (!isPhantomJS) {
expect(tabImage2).toBeDefined();
expect(tabImage2.outerHTML).toMatch("src=\"https?://res\.cloudinary\.com/" + CLOUD_NAME + "/image/upload/c_scale,w_400/sample.jpg\"");
}
done();
};
// testWindow.addEventListener('resize', listener);
setTimeout(listener, 2000);
testWindow.resizeTo(350, 800);
testWindow && testWindow.resizeTo(350, 800);
});
it('should apply responsive if "width" is not defined', function () {
element = $compile("<div><cl-image public_id='{{testPublicId}}' responsive/></div>")($rootScope);
Expand Down
3 changes: 2 additions & 1 deletion spec/responsive-core-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ <h1>Bootstrap &amp; Cloudinary Responsive Images</h1>
<!-- Tab panes -->
<div class="tab-content row">
<div role="tabpanel" class="tab-pane active" id="home">
<a href="#"><cl-image id="tabImage2" width="auto" crop="{{ cropValue || 'scale'}}" public_id="sample.jpg" responsive class="col-xs-12"/>
<a href="#">
<cl-image id="tabImage2" width="auto" crop="{{ cropValue || 'scale'}}" public_id="sample.jpg" responsive class="col-xs-12"/>
</a>
<cl-image id="tabImage3" public_id="sample.jpg" width="auto" crop="scale" effect="sepia" responsive class="col-xs-12"/>
</div>
Expand Down