From 799cd19f45e367404a1d24b26596b1922d2a2b79 Mon Sep 17 00:00:00 2001 From: Eitan Peer Date: Sun, 4 Jun 2017 08:21:03 +0300 Subject: [PATCH 1/7] Fix link to Angular SDK --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f78345e..f06decc7 100644 --- a/README.md +++ b/README.md @@ -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. From c4a47a8e907da2f91510438eb359a487ea2d5097 Mon Sep 17 00:00:00 2001 From: rtlcoil Date: Mon, 18 Sep 2017 18:35:00 +0300 Subject: [PATCH 2/7] cl-image ignores a cl-transformation if it has an ng-if #105 -fixed bug -corrected tests --- bower.json | 6 ++++-- js/angular.cloudinary.js | 1 + package.json | 2 +- spec/cloudinary_spec.js | 21 +++++++++++++++------ spec/responsive-core-test.html | 3 ++- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/bower.json b/bower.json index 2497dec1..a56113d7 100644 --- a/bower.json +++ b/bower.json @@ -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", @@ -43,6 +44,7 @@ "karma*" ], "devDependencies": { - "angular-mocks": "^1.5.1" + "angular-mocks": "^1.5.1", + "bootstrap": "^3.3.7" } } diff --git a/js/angular.cloudinary.js b/js/angular.cloudinary.js index c4e11188..7b36c624 100644 --- a/js/angular.cloudinary.js +++ b/js/angular.cloudinary.js @@ -88,6 +88,7 @@ return { restrict : 'E', transclude : false, + priority: 600, require: '^clImage', link : function (scope, element, attrs, clImageCtrl) { clImageCtrl.addTransformation(toCloudinaryAttributes(attrs, /^[^$]/)); diff --git a/package.json b/package.json index f23756ab..504e9103 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "test": "test" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "karma start karma.conf.js" }, "repository": { "type": "git", diff --git a/spec/cloudinary_spec.js b/spec/cloudinary_spec.js index 44924474..0e27b01b 100644 --- a/spec/cloudinary_spec.js +++ b/spec/cloudinary_spec.js @@ -140,27 +140,36 @@ describe("cloudinary", function () { testWindow.addEventListener('load', function () { image1 = testWindow.document.getElementById("image1"); - tabImage2 = testWindow.document.getElementById("tabImage2"); + tabImage2 = testWindow.document.getElementById("tabImage2") + + console.log(tabImage2, '(load) 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 (tabImage2){ + 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 (tabImage2){ + 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("
")($rootScope); diff --git a/spec/responsive-core-test.html b/spec/responsive-core-test.html index da5dbbf1..3a9c20b4 100644 --- a/spec/responsive-core-test.html +++ b/spec/responsive-core-test.html @@ -37,7 +37,8 @@

Bootstrap & Cloudinary Responsive Images

From be89910d97913b0051e958a0976ac4e62c484cd0 Mon Sep 17 00:00:00 2001 From: rtlcoil Date: Mon, 18 Sep 2017 19:07:59 +0300 Subject: [PATCH 3/7] fix travis --- .gitignore | 2 +- .travis.yml | 9 +++++++++ spec/config.js | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 spec/config.js diff --git a/.gitignore b/.gitignore index 425b26b7..9e19ca97 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ logs *.log npm-debug.log* -config.js +#config.js # Coverage directory used by tools like istanbul coverage diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..c26273f9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +sudo: false +node_js: + - '6' + +cache: + yarn: true + directories: + - bower_components \ No newline at end of file diff --git a/spec/config.js b/spec/config.js new file mode 100644 index 00000000..7d3e7929 --- /dev/null +++ b/spec/config.js @@ -0,0 +1,7 @@ +var app = angular.module("spec", ["cloudinary"]); +app.config(['cloudinaryProvider', function (cloudinaryProvider) { + cloudinaryProvider + .set("cloud_name", "sdk-test") + .set("upload_preset", "UUUUUUUU"); +}]); +app.controller("specController", ["$scope",function($scope){}]); \ No newline at end of file From fccc48ffff74df68db177ab799e3ee1bfc69944d Mon Sep 17 00:00:00 2001 From: rtlcoil Date: Mon, 18 Sep 2017 19:17:30 +0300 Subject: [PATCH 4/7] Change config .travis.yml --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c26273f9..adaa6ea6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,13 @@ 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: yarn: true directories: From 420480d887defb5ac1fe2d1c748608019de74676 Mon Sep 17 00:00:00 2001 From: rtlcoil Date: Mon, 18 Sep 2017 19:19:40 +0300 Subject: [PATCH 5/7] Change config .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index adaa6ea6..972b7070 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ node_js: before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - install: +install: - npm install - npm install bower - bower install From 5976b395151033907d33b1313aef69acc060fb64 Mon Sep 17 00:00:00 2001 From: rtlcoil Date: Mon, 18 Sep 2017 19:24:49 +0300 Subject: [PATCH 6/7] last changes .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 972b7070..8b8eb6f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,6 @@ install: - npm install bower - bower install cache: - yarn: true directories: - - bower_components \ No newline at end of file + - bower_components + - node_modules \ No newline at end of file From 4c08dbb41e7348f50e0e7d5f154d12e5a701d5dd Mon Sep 17 00:00:00 2001 From: rtlcoil Date: Thu, 5 Oct 2017 21:49:12 +0300 Subject: [PATCH 7/7] fix comments --- .gitignore | 2 +- spec/cloudinary_spec.js | 71 +++++++++++++++++++++-------------------- spec/config.js | 7 ---- 3 files changed, 37 insertions(+), 43 deletions(-) delete mode 100644 spec/config.js diff --git a/.gitignore b/.gitignore index 9e19ca97..425b26b7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ logs *.log npm-debug.log* -#config.js +config.js # Coverage directory used by tools like istanbul coverage diff --git a/spec/cloudinary_spec.js b/spec/cloudinary_spec.js index 0e27b01b..0bbe84d9 100644 --- a/spec/cloudinary_spec.js +++ b/spec/cloudinary_spec.js @@ -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) { @@ -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("
")($rootScope); $rootScope.$digest(); @@ -79,9 +78,9 @@ 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("
")($rootScope); $rootScope.$digest(); @@ -89,42 +88,42 @@ describe("cloudinary", function () { // 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("
")($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("
" + - "" + - ""+ - "" + - ""+ - "" + + var element = $compile("
" + + "" + + "" + + "" + + "" + + "" + "
")($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("
" + - "" + - ""+ - "" + - ""+ + var element = $compile("
" + + "" + + "" + + "" + + "" + "" + - "" + - ""+ - "" + + "" + + "" + + "" + "
")($rootScope); $rootScope.$digest(); @@ -132,17 +131,17 @@ describe("cloudinary", function () { 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") + tabImage2 = testWindow.document.getElementById("tabImage2"); - console.log(tabImage2, '(load) tabImage2'); expect(tabImage2).toBeDefined(); done(); }); @@ -154,7 +153,8 @@ describe("cloudinary", function () { testWindow && testWindow.close(); }); it('should enable responsive functionality', function (done) { - if (tabImage2){ + 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(); @@ -162,7 +162,8 @@ describe("cloudinary", function () { it("should react to a change in the parent's width", function (done) { var listener = function () { - if (tabImage2){ + 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(); diff --git a/spec/config.js b/spec/config.js deleted file mode 100644 index 7d3e7929..00000000 --- a/spec/config.js +++ /dev/null @@ -1,7 +0,0 @@ -var app = angular.module("spec", ["cloudinary"]); -app.config(['cloudinaryProvider', function (cloudinaryProvider) { - cloudinaryProvider - .set("cloud_name", "sdk-test") - .set("upload_preset", "UUUUUUUU"); -}]); -app.controller("specController", ["$scope",function($scope){}]); \ No newline at end of file