From fb533db71cf95759f30372c0b4e424c8f192feb4 Mon Sep 17 00:00:00 2001 From: Raya Straus Date: Mon, 22 Jun 2020 13:42:45 +0300 Subject: [PATCH] Added comma dangle rule --- .eslintrc.js | 2 +- babel.config.js | 8 +- lib/api.js | 28 +- lib/api_client/call_account_api.js | 2 +- lib/api_client/call_api.js | 2 +- lib/api_client/execute_request.js | 18 +- lib/cache.js | 10 +- lib/cache/KeyValueCacheAdapter.js | 4 +- lib/cloudinary.js | 4 +- lib/config.js | 4 +- lib/preloaded_file.js | 2 +- lib/provisioning/account.js | 18 +- lib/uploader.js | 80 +-- lib/utils/consts.js | 16 +- lib/utils/index.js | 50 +- lib/utils/srcsetUtils.js | 2 +- lib/v2/api.js | 2 +- lib/v2/index.js | 2 +- lib/v2/search.js | 2 +- lib/v2/uploader.js | 2 +- samples/basic/basic.js | 2 +- samples/photo_album/config/schema.js | 2 +- .../controllers/photos_controller.js | 8 +- samples/photo_album/server.js | 2 +- test/access_control_spec.js | 12 +- test/archivespec.js | 30 +- test/cache_spec.js | 16 +- test/cloudinary_spec.js | 202 +++---- test/integration/api/admin/api_spec.js | 178 +++--- .../api/provisioning/account_spec.js | 4 +- test/integration/api/search/search_spec.js | 36 +- .../integration/api/uploader/uploader_spec.js | 218 ++++---- test/source_tag_spec.js | 26 +- test/spechelper.js | 10 +- test/streaming_profiles_spec.js | 52 +- test/structured_metadata_spec.js | 82 +-- test/testUtils/assertions/beADatasource.js | 2 +- test/testUtils/createTestConfig.js | 2 +- test/testUtils/testConstants.js | 12 +- test/unit/authToken/authTokenImageTag_spec.js | 4 +- test/unit/authToken/authTokenURL_spec.js | 20 +- test/unit/authToken/authTokenUtils_spec.js | 6 +- .../utils/commonAuthSetupAndTeardown.js | 2 +- test/unit/cache/KeyValueCacheAdapter_spec.js | 6 +- test/unit/tags/image_spec.js | 116 ++-- test/unit/tags/video_spec.js | 84 +-- test/unit/url/video_url_spec.js | 52 +- test/utils/get_sdk_versionID_spec.js | 8 +- test/utils/image_versionID_spec.js | 12 +- test/utils/utils_spec.js | 520 +++++++++--------- tools/createTestCloud.js | 4 +- 51 files changed, 994 insertions(+), 994 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ea96f893..6f04d4b6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,7 +18,7 @@ module.exports = { "arrow-parens": "off", "camelcase": "off", "class-methods-use-this": "off", - "comma-dangle": "off", + "comma-dangle": ["error", "never"], "comma-spacing":["error", {"before": false, "after": true}], "consistent-return": "off", "dot-notation": "error", diff --git a/babel.config.js b/babel.config.js index bcdad22c..d9defe81 100644 --- a/babel.config.js +++ b/babel.config.js @@ -3,11 +3,11 @@ const presets = [ [ "env", { - targets: { node: "4" }, - }, + targets: { node: "4" } + } ], - "stage-0", - ], + "stage-0" + ] ]; const plugins = ["transform-object-rest-spread"]; diff --git a/lib/api.js b/lib/api.js index 754a249c..eb8bef72 100644 --- a/lib/api.js +++ b/lib/api.js @@ -87,7 +87,7 @@ exports.restore = function restore(public_ids, callback, options = {}) { uri = ["resources", resource_type, type, "restore"]; return call_api("post", uri, { public_ids: public_ids, - versions: options.versions, + versions: options.versions }, callback, options); }; @@ -109,7 +109,7 @@ exports.delete_resources = function delete_resources(public_ids, callback, optio type = options.type || "upload"; uri = ["resources", resource_type, type]; return call_api("delete", uri, deleteResourcesParams(options, { - "public_ids[]": public_ids, + "public_ids[]": public_ids }), callback, options); }; @@ -119,7 +119,7 @@ exports.delete_resources_by_prefix = function delete_resources_by_prefix(prefix, type = options.type || "upload"; uri = ["resources", resource_type, type]; return call_api("delete", uri, deleteResourcesParams(options, { - prefix: prefix, + prefix: prefix }), callback, options); }; @@ -137,7 +137,7 @@ exports.delete_all_resources = function delete_all_resources(callback, options = type = options.type || "upload"; uri = ["resources", resource_type, type]; return call_api("delete", uri, deleteResourcesParams(options, { - all: true, + all: true }), callback, options); }; @@ -145,7 +145,7 @@ exports.delete_derived_resources = function delete_derived_resources(derived_res let uri; uri = ["derived_resources"]; return call_api("delete", uri, { - "derived_resource_ids[]": derived_resource_ids, + "derived_resource_ids[]": derived_resource_ids }, callback, options); }; @@ -153,14 +153,14 @@ exports.delete_derived_by_transformation = function delete_derived_by_transforma public_ids, transformations, callback, - options = {}, + options = {} ) { let params, resource_type, type, uri; resource_type = options.resource_type || "image"; type = options.type || "upload"; uri = "resources/" + resource_type + "/" + type; params = extend({ - "public_ids[]": public_ids, + "public_ids[]": public_ids }, pickOnlyExistingValues(options, "invalidate")); params.keep_original = true; params.transformations = utils.build_eager(transformations); @@ -279,13 +279,13 @@ exports.upload_mapping = function upload_mapping(name, callback, options = {}) { name = null; } return call_api("get", 'upload_mappings', { - folder: name, + folder: name }, callback, options); }; exports.delete_upload_mapping = function delete_upload_mapping(name, callback, options = {}) { return call_api("delete", 'upload_mappings', { - folder: name, + folder: name }, callback, options); }; @@ -310,7 +310,7 @@ function publishResource(byKey, value, callback, options = {}) { resource_type = options.resource_type || "image"; uri = ["resources", resource_type, "publish_resources"]; options = extend({ - resource_type: resource_type, + resource_type: resource_type }, options); return call_api("post", uri, params, callback, options); } @@ -357,7 +357,7 @@ function updateResourcesAccessMode(access_mode, by_key, value, callback, options resource_type = options.resource_type || "image"; type = options.type || "upload"; params = { - access_mode: access_mode, + access_mode: access_mode }; params[by_key] = value; return call_api("post", "resources/" + resource_type + "/" + type + "/update_access_mode", params, callback, options); @@ -372,7 +372,7 @@ exports.update_resources_access_mode_by_prefix = function update_resources_acces access_mode, prefix, callback, - options = {}, + options = {} ) { return updateResourcesAccessMode(access_mode, "prefix", prefix, callback, options); }; @@ -381,7 +381,7 @@ exports.update_resources_access_mode_by_tag = function update_resources_access_m access_mode, tag, callback, - options = {}, + options = {} ) { return updateResourcesAccessMode(access_mode, "tag", tag, callback, options); }; @@ -390,7 +390,7 @@ exports.update_resources_access_mode_by_ids = function update_resources_access_m access_mode, ids, callback, - options = {}, + options = {} ) { return updateResourcesAccessMode(access_mode, "public_ids[]", ids, callback, options); }; diff --git a/lib/api_client/call_account_api.js b/lib/api_client/call_account_api.js index 0bce05c6..1df492a7 100644 --- a/lib/api_client/call_account_api.js +++ b/lib/api_client/call_account_api.js @@ -13,7 +13,7 @@ function call_account_api(method, uri, params, callback, options) { const api_url = [cloudinary, "v1_1", "provisioning", "accounts", account_id].concat(uri).join("/"); const auth = { key: ensureOption(options, "provisioning_api_key"), - secret: ensureOption(options, "provisioning_api_secret"), + secret: ensureOption(options, "provisioning_api_secret") }; return execute_request(method, params, auth, api_url, callback, options); diff --git a/lib/api_client/call_api.js b/lib/api_client/call_api.js index 66807bd7..372df6eb 100644 --- a/lib/api_client/call_api.js +++ b/lib/api_client/call_api.js @@ -13,7 +13,7 @@ function call_api(method, uri, params, callback, options) { const api_url = [cloudinary, "v1_1", cloud_name].concat(uri).join("/"); const auth = { key: ensureOption(options, "api_key"), - secret: ensureOption(options, "api_secret"), + secret: ensureOption(options, "api_secret") }; return execute_request(method, params, auth, api_url, callback, options); diff --git a/lib/api_client/execute_request.js b/lib/api_client/execute_request.js index 381cfa89..00b1cae9 100644 --- a/lib/api_client/execute_request.js +++ b/lib/api_client/execute_request.js @@ -35,9 +35,9 @@ function execute_request(method, params, auth, api_url, callback, options = {}) method: method, headers: { 'Content-Type': content_type, - 'User-Agent': utils.getUserAgent(), + 'User-Agent': utils.getUserAgent() }, - auth: key + ":" + secret, + auth: key + ":" + secret }); if (options.agent != null) { request_options.agent = options.agent; @@ -63,8 +63,8 @@ function execute_request(method, params, auth, api_url, callback, options = {}) } catch (e) { result = { error: { - message: "Server return invalid JSON response. Status Code " + res.statusCode, - }, + message: "Server return invalid JSON response. Status Code " + res.statusCode + } }; } @@ -79,7 +79,7 @@ function execute_request(method, params, auth, api_url, callback, options = {}) if (result.error) { deferred.reject(Object.assign({ request_options, - query_params, + query_params }, result)); } else { deferred.resolve(result); @@ -95,8 +95,8 @@ function execute_request(method, params, auth, api_url, callback, options = {}) message: e, http_code: res.statusCode, request_options, - query_params, - }, + query_params + } }; deferred.reject(err_obj.error); if (typeof callback === "function") { @@ -109,8 +109,8 @@ function execute_request(method, params, auth, api_url, callback, options = {}) message: "Server returned unexpected status code - " + res.statusCode, http_code: res.statusCode, request_options, - query_params, - }, + query_params + } }; deferred.reject(err_obj.error); if (typeof callback === "function") { diff --git a/lib/cache.js b/lib/cache.js index 116fec61..6e402726 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -76,7 +76,7 @@ const Cache = { publicId, options.type || 'upload', options.resource_type || 'image', transformation, - options.format, + options.format ); }, /** @@ -96,7 +96,7 @@ const Cache = { options.resource_type || 'image', transformation, options.format, - value, + value ); }, /** @@ -106,7 +106,7 @@ const Cache = { flushAll() { if (!this.adapter) { return undefined; } return this.adapter.flushAll(); - }, + } }; @@ -114,7 +114,7 @@ const Cache = { Object.defineProperty(Cache, "instance", { get() { return global[CACHE]; - }, + } }); Object.defineProperty(Cache, "adapter", { /** @@ -130,7 +130,7 @@ Object.defineProperty(Cache, "adapter", { */ set(adapter) { global[CACHE_ADAPTER] = adapter; - }, + } }); Object.freeze(Cache); diff --git a/lib/cache/KeyValueCacheAdapter.js b/lib/cache/KeyValueCacheAdapter.js index 61c21c4c..f49531c4 100644 --- a/lib/cache/KeyValueCacheAdapter.js +++ b/lib/cache/KeyValueCacheAdapter.js @@ -27,8 +27,8 @@ class KeyValueCacheAdapter extends CacheAdapter { resourceType, transformation, format, - value, - ), + value + ) ); } diff --git a/lib/cloudinary.js b/lib/cloudinary.js index 40292b2b..6c0d00fd 100644 --- a/lib/cloudinary.js +++ b/lib/cloudinary.js @@ -6,7 +6,7 @@ exports.api = require("./api"); let account = require("./provisioning/account"); exports.provisioning = { - account: account, + account: account }; exports.PreloadedFile = require("./preloaded_file"); exports.Cache = require('./cache'); @@ -155,7 +155,7 @@ exports.video = function video(public_id, options) { if (multi_source_types && !has_sources) { sources = source_types.map(source_type => ({ type: source_type, - transformations: source_transformation[source_type] || {}, + transformations: source_transformation[source_type] || {} })); } if (_.isArray(sources) && sources.length > 0) { diff --git a/lib/config.js b/lib/config.js index e5621d49..6b4107a7 100644 --- a/lib/config.js +++ b/lib/config.js @@ -55,13 +55,13 @@ function parseCloudinaryConfigFromEnvURL(ENV_STR) { api_key: uri.auth && uri.auth.split(":")[0], api_secret: uri.auth && uri.auth.split(":")[1], private_cdn: uri.pathname != null, - secure_distribution: uri.pathname && uri.pathname.substring(1), + secure_distribution: uri.pathname && uri.pathname.substring(1) }); } else if (uri.protocol === 'account:') { conf = Object.assign({}, conf, { account_id: uri.host, provisioning_api_key: uri.auth && uri.auth.split(":")[0], - provisioning_api_secret: uri.auth && uri.auth.split(":")[1], + provisioning_api_secret: uri.auth && uri.auth.split(":")[1] }); } diff --git a/lib/preloaded_file.js b/lib/preloaded_file.js index 3eba7092..e5e9f514 100644 --- a/lib/preloaded_file.js +++ b/lib/preloaded_file.js @@ -27,7 +27,7 @@ class PreloadedFile { let expected_signature; expected_signature = utils.api_sign_request({ public_id: this.public_id, - version: this.version, + version: this.version }, config().api_secret); return this.signature === expected_signature; } diff --git a/lib/provisioning/account.js b/lib/provisioning/account.js index 50bc1f69..23146f64 100644 --- a/lib/provisioning/account.js +++ b/lib/provisioning/account.js @@ -13,7 +13,7 @@ function sub_accounts(enabled, ids = [], prefix, options = {}, callback) { let params = { enabled, ids, - prefix, + prefix }; let uri = ['sub_accounts']; @@ -55,7 +55,7 @@ function create_sub_account(name, cloud_name, custom_attributes, enabled, base_a name, custom_attributes: custom_attributes, enabled, - base_sub_account_id: base_account, + base_sub_account_id: base_account }; options.content_type = "json"; @@ -93,7 +93,7 @@ function update_sub_account(sub_account_id, name, cloud_name, custom_attributes, cloud_name: cloud_name, name, custom_attributes: custom_attributes, - enabled, + enabled }; options.content_type = "json"; @@ -125,7 +125,7 @@ function user(user_id, options = {}, callback) { function users(pending, user_ids, prefix, sub_account_id, options = {}, callback) { let uri = ['users']; let params = { - ids: user_ids, + ids: user_ids }; return call_account_api('GET', uri, params, callback, options); } @@ -147,7 +147,7 @@ function create_user(name, email, role, sub_account_ids, options = {}, callback) name, email, role, - sub_account_ids: sub_account_ids, + sub_account_ids: sub_account_ids }; options.content_type = 'json'; return call_account_api('POST', uri, params, callback, options); @@ -171,7 +171,7 @@ function update_user(user_id, name, email, role, sub_account_ids, options = {}, name, email, role, - sub_account_ids: sub_account_ids, + sub_account_ids: sub_account_ids }; options.content_type = 'json'; return call_account_api('PUT', uri, params, callback, options); @@ -198,7 +198,7 @@ function create_user_group(name, options = {}, callback) { let uri = ['user_groups']; options.content_type = 'json'; let params = { - name, + name }; return call_account_api('POST', uri, params, callback, options); } @@ -213,7 +213,7 @@ function create_user_group(name, options = {}, callback) { function update_user_group(group_id, name, options = {}, callback) { let uri = ['user_groups', group_id]; let params = { - name, + name }; return call_account_api('PUT', uri, params, callback, options); } @@ -304,5 +304,5 @@ module.exports = { create_user, create_user_group, add_user_to_group, - delete_user_group, + delete_user_group }; diff --git a/lib/uploader.js b/lib/uploader.js index 5b9a5be7..29267c71 100644 --- a/lib/uploader.js +++ b/lib/uploader.js @@ -21,26 +21,26 @@ const { isObject, isRemoteUrl, merge, - pickOnlyExistingValues, + pickOnlyExistingValues } = utils; exports.unsigned_upload_stream = function unsigned_upload_stream(upload_preset, callback, options = {}) { return exports.upload_stream(callback, merge(options, { unsigned: true, - upload_preset: upload_preset, + upload_preset: upload_preset })); }; exports.upload_stream = function upload_stream(callback, options = {}) { return exports.upload(null, callback, extend({ - stream: true, + stream: true }, options)); }; exports.unsigned_upload = function unsigned_upload(file, upload_preset, callback, options = {}) { return exports.upload(file, callback, merge(options, { unsigned: true, - upload_preset: upload_preset, + upload_preset: upload_preset })); }; @@ -60,7 +60,7 @@ exports.upload_large = function upload_large(path, callback, options = {}) { options.filename = path.split(/(\\|\/)/g).pop().replace(/\.[^/.]+$/, ""); } return exports.upload_chunked(path, callback, extend({ - resource_type: 'raw', + resource_type: 'raw' }, options)); }; @@ -107,19 +107,19 @@ class Chunkable extends Writable { exports.upload_large_stream = function upload_large_stream(_unused_, callback, options = {}) { return exports.upload_chunked_stream(callback, extend({ - resource_type: 'raw', + resource_type: 'raw' }, options)); }; exports.upload_chunked_stream = function upload_chunked_stream(callback, options = {}) { options = extend({}, options, { - stream: true, + stream: true }); options.x_unique_upload_id = utils.random_public_id(); let params = build_upload_params(options); let chunk_size = options.chunk_size != null ? options.chunk_size : options.part_size; let chunker = new Chunkable({ - chunk_size: chunk_size, + chunk_size: chunk_size }); let sent = 0; chunker.on('ready', function (buffer, is_last, done) { @@ -173,8 +173,8 @@ exports.destroy = function destroy(public_id, callback, options = {}) { timestamp: utils.timestamp(), type: options.type, invalidate: options.invalidate, - public_id: public_id, - }, + public_id: public_id + } ]; }); }; @@ -189,8 +189,8 @@ exports.rename = function rename(from_public_id, to_public_id, callback, options to_public_id: to_public_id, overwrite: options.overwrite, invalidate: options.invalidate, - to_type: options.to_type, - }, + to_type: options.to_type + } ]; }); }; @@ -203,7 +203,7 @@ exports.text = function text(content, callback, options = {}) { let params = { timestamp: utils.timestamp(), text: content, - ...textParams, + ...textParams }; return [params]; @@ -213,7 +213,7 @@ exports.text = function text(content, callback, options = {}) { exports.generate_sprite = function generate_sprite(tag, callback, options = {}) { return call_api("sprite", callback, options, function () { const transformation = utils.generate_transformation_string(extend({}, options, { - fetch_format: options.format, + fetch_format: options.format })); return [ { @@ -221,8 +221,8 @@ exports.generate_sprite = function generate_sprite(tag, callback, options = {}) tag: tag, transformation: transformation, async: options.async, - notification_url: options.notification_url, - }, + notification_url: options.notification_url + } ]; }); }; @@ -237,8 +237,8 @@ exports.multi = function multi(tag, callback, options = {}) { transformation: transformation, format: options.format, async: options.async, - notification_url: options.notification_url, - }, + notification_url: options.notification_url + } ]; }); }; @@ -253,8 +253,8 @@ exports.explode = function explode(public_id, callback, options = {}) { transformation: transformation, format: options.format, type: options.type, - notification_url: options.notification_url, - }, + notification_url: options.notification_url + } ]; }); }; @@ -284,7 +284,7 @@ function call_tags_api(tag, command, public_ids = [], callback, options = {}) { timestamp: utils.timestamp(), public_ids: utils.build_array(public_ids), command: command, - type: options.type, + type: options.type }; if (tag != null) { params.tag = tag; @@ -307,7 +307,7 @@ function call_context_api(context, command, public_ids = [], callback, options = timestamp: utils.timestamp(), public_ids: utils.build_array(public_ids), command: command, - type: options.type, + type: options.type }; if (context != null) { params.context = utils.encode_context(context); @@ -331,8 +331,8 @@ function cacheResults(result, { type, resource_type }) { breakpoints }) => Cache.set( result.public_id, { type, resource_type, raw_transformation: transformation, format: extname(breakpoints[0].url).slice(1) }, - breakpoints.map(i => i.width), - ), + breakpoints.map(i => i.width) + ) ); } } @@ -349,8 +349,8 @@ function parseResult(buffer, res) { result = { error: { message: `Server return invalid JSON response. Status Code ${res.statusCode}. ${jsonError}`, - name: "Error", - }, + name: "Error" + } }; } return result; @@ -410,7 +410,7 @@ function call_api(action, callback, options, get_params) { let error = { message: `Server returned unexpected status code - ${res.statusCode}`, http_code: res.statusCode, - name: "UnexpectedResponse", + name: "UnexpectedResponse" }; deferred.reject(error); callback({ error }); @@ -419,7 +419,7 @@ function call_api(action, callback, options, get_params) { let post_data = utils.hashToParameters(params) .filter(([key, value]) => value != null) .map( - ([key, value]) => Buffer.from(encodeFieldPart(boundary, key, value), 'utf8'), + ([key, value]) => Buffer.from(encodeFieldPart(boundary, key, value), 'utf8') ); let result = post(api_url, post_data, boundary, file, handle_response, options); @@ -440,7 +440,7 @@ function post(url, post_data, boundary, file, callback, options) { let post_options = urlLib.parse(url); let headers = { 'Content-Type': `multipart/form-data; boundary=${boundary}`, - 'User-Agent': utils.getUserAgent(), + 'User-Agent': utils.getUserAgent() }; if (options.content_range != null) { headers['Content-Range'] = options.content_range; @@ -450,7 +450,7 @@ function post(url, post_data, boundary, file, callback, options) { } post_options = extend(post_options, { method: 'POST', - headers: headers, + headers: headers }); if (options.agent != null) { post_options.agent = options.agent; @@ -464,7 +464,7 @@ function post(url, post_data, boundary, file, callback, options) { error = { message: "Request Timeout", http_code: 499, - name: "TimeoutError", + name: "TimeoutError" }; } return callback({ error }); @@ -482,7 +482,7 @@ function post(url, post_data, boundary, file, callback, options) { post_request.write(file_header); fs.createReadStream(file).on('error', function (error) { callback({ - error: error, + error: error }); return post_request.abort(); }).pipe(upload_stream); @@ -499,7 +499,7 @@ function encodeFieldPart(boundary, name, value) { `Content-Disposition: form-data; name="${name}"`, '', value, - '', + '' ].join("\r\n"); } @@ -509,13 +509,13 @@ function encodeFilePart(boundary, type, name, filename) { `Content-Disposition: form-data; name="${name}"; filename="${filename}"`, `Content-Type: ${type}`, '', - '', + '' ].join("\r\n"); } exports.direct_upload = function direct_upload(callback_url, options = {}) { let params = build_upload_params(extend({ - callback: callback_url, + callback: callback_url }, options)); params = utils.process_request_params(params, options); let api_url = utils.api_url("upload", options); @@ -524,8 +524,8 @@ exports.direct_upload = function direct_upload(callback_url, options = {}) { form_attrs: { action: api_url, method: "POST", - enctype: "multipart/form-data", - }, + enctype: "multipart/form-data" + } }; }; @@ -551,7 +551,7 @@ exports.image_upload_tag = function image_upload_tag(field, options = {}) { "data-form-data": exports.upload_tag_params(options), "data-cloudinary-field": field, "data-max-chunk-size": options.chunk_size, - "class": [html_options.class, "cloudinary-fileupload"].join(" "), + "class": [html_options.class, "cloudinary-fileupload"].join(" ") }, html_options); return ``; }; @@ -559,7 +559,7 @@ exports.image_upload_tag = function image_upload_tag(field, options = {}) { exports.unsigned_image_upload_tag = function unsigned_image_upload_tag(field, upload_preset, options = {}) { return exports.image_upload_tag(field, merge(options, { unsigned: true, - upload_preset: upload_preset, + upload_preset: upload_preset })); }; @@ -580,7 +580,7 @@ exports.update_metadata = function update_metadata(metadata, public_ids, callbac metadata: utils.encode_context(metadata), public_ids: utils.build_array(public_ids), timestamp: utils.timestamp(), - type: options.type, + type: options.type }; return [params]; }); diff --git a/lib/utils/consts.js b/lib/utils/consts.js index b76bf565..38a57a71 100644 --- a/lib/utils/consts.js +++ b/lib/utils/consts.js @@ -1,11 +1,11 @@ const DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION = { width: "auto", - crop: "limit", + crop: "limit" }; const DEFAULT_POSTER_OPTIONS = { format: 'jpg', - resource_type: 'video', + resource_type: 'video' }; const DEFAULT_VIDEO_SOURCE_TYPES = ['webm', 'mp4', 'ogv']; @@ -23,7 +23,7 @@ const CONDITIONAL_OPERATORS = { "/": "div", "+": "add", "-": "sub", - "^": "pow", + "^": "pow" }; let SIMPLE_PARAMS = [ @@ -43,7 +43,7 @@ let SIMPLE_PARAMS = [ ["start_offset", "so"], ["streaming_profile", "sp"], ["video_codec", "vc"], - ["video_sampling", "vs"], + ["video_sampling", "vs"] ]; const PREDEFINED_VARS = { @@ -70,7 +70,7 @@ const PREDEFINED_VARS = { "pageX": "px", "pageY": "py", "tags": "tags", - "width": "w", + "width": "w" }; const TRANSFORMATION_PARAMS = [ @@ -118,7 +118,7 @@ const TRANSFORMATION_PARAMS = [ 'width', 'x', 'y', - 'zoom', // + any key that starts with '$' + 'zoom' // + any key that starts with '$' ]; const LAYER_KEYWORD_PARAMS = { @@ -126,7 +126,7 @@ const LAYER_KEYWORD_PARAMS = { font_style: "normal", text_decoration: "none", text_align: null, - stroke: "none", + stroke: "none" }; module.exports = { @@ -137,5 +137,5 @@ module.exports = { PREDEFINED_VARS, LAYER_KEYWORD_PARAMS, TRANSFORMATION_PARAMS, - SIMPLE_PARAMS, + SIMPLE_PARAMS }; diff --git a/lib/utils/index.js b/lib/utils/index.js index 76a898f2..453b756f 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -83,7 +83,7 @@ const { PREDEFINED_VARS, LAYER_KEYWORD_PARAMS, TRANSFORMATION_PARAMS, - SIMPLE_PARAMS, + SIMPLE_PARAMS } = require('./consts'); function textStyle(layer) { @@ -308,7 +308,7 @@ function build_upload_params(options) { unique_filename: utils.as_safe_bool(options.unique_filename), upload_preset: options.upload_preset, use_filename: utils.as_safe_bool(options.use_filename), - quality_override: options.quality_override, + quality_override: options.quality_override }; return utils.updateable_resource_params(options, params); } @@ -396,7 +396,7 @@ function generate_transformation_string(options) { effect = effect.join(":"); } else if (isObject(effect)) { effect = entries(effect).map( - ([key, value]) => `${key}:${value}`, + ([key, value]) => `${key}:${value}` ); } let border = consumeOption(options, "border"); @@ -444,7 +444,7 @@ function generate_transformation_string(options) { w: normalize_expression(width), x: normalize_expression(consumeOption(options, "x")), y: normalize_expression(consumeOption(options, "y")), - z: normalize_expression(consumeOption(options, "zoom")), + z: normalize_expression(consumeOption(options, "zoom")) }; SIMPLE_PARAMS.forEach(([name, short]) => { @@ -469,7 +469,7 @@ function generate_transformation_string(options) { delete options[key]; return `${key}_${normalize_expression(value)}`; }).sort().concat( - variablesParam.map(([name, value]) => `${name}_${normalize_expression(value)}`), + variablesParam.map(([name, value]) => `${name}_${normalize_expression(value)}`) ).join(','); let transformations = entries(params) @@ -572,7 +572,7 @@ const URL_KEYS = [ 'type', 'url_suffix', 'use_root_path', - 'version', + 'version' ]; /** @@ -698,7 +698,7 @@ function url(public_id, options = {}) { secure_cdn_subdomain, cname, secure, - secure_distribution, + secure_distribution ); let resultUrl = [prefix, resource_type, type, signature, transformation, version, public_id].filter(function (part) { return (part != null) && part !== ''; @@ -715,7 +715,7 @@ function url(public_id, options = {}) { if (analytics === true) { let sdkVersionID = getSDKVersionID({ - responsive, + responsive }); // url might already have a '?' query param let appender = '?'; @@ -730,7 +730,7 @@ function url(public_id, options = {}) { function video_url(public_id, options) { options = extend({ - resource_type: 'video', + resource_type: 'video' }, options); return utils.url(public_id, options); } @@ -821,7 +821,7 @@ function unsigned_url_prefix( secure_cdn_subdomain, cname, secure, - secure_distribution, + secure_distribution ) { let prefix; if (cloud_name.indexOf("/") === 0) { @@ -874,9 +874,9 @@ function signed_preloaded_image(result) { function api_sign_request(params_to_sign, api_secret) { let to_sign = entries(params_to_sign).filter( - ([k, v]) => utils.present(v), + ([k, v]) => utils.present(v) ).map( - ([k, v]) => `${k}=${toArray(v).join(",")}`, + ([k, v]) => `${k}=${toArray(v).join(",")}` ).sort().join("&"); let shasum = crypto.createHash('sha1'); shasum.update(utf8_encode(to_sign + api_secret), 'binary'); @@ -886,9 +886,9 @@ function api_sign_request(params_to_sign, api_secret) { function clear_blank(hash) { let filtered_hash = {}; entries(hash).filter( - ([k, v]) => utils.present(v), + ([k, v]) => utils.present(v) ).forEach( - ([k, v]) => { filtered_hash[k] = v; }, + ([k, v]) => { filtered_hash[k] = v; } ); return filtered_hash; } @@ -953,7 +953,7 @@ function private_download_url(public_id, format, options = {}) { format: format, type: options.type, attachment: options.attachment, - expires_at: options.expires_at, + expires_at: options.expires_at }, options); return exports.api_url("download", options) + "?" + querystring.stringify(params); } @@ -967,7 +967,7 @@ function zip_download_url(tag, options = {}) { let params = exports.sign_request({ timestamp: options.timestamp || exports.timestamp(), tag: tag, - transformation: utils.generate_transformation_string(options), + transformation: utils.generate_transformation_string(options) }, options); return exports.api_url("download_tag.zip", options) + "?" + hashToQuery(params); } @@ -1008,7 +1008,7 @@ function zip_download_url(tag, options = {}) { */ function download_archive_url(options = {}) { let cloudinary_params = exports.sign_request(exports.archive_params(merge(options, { - mode: "download", + mode: "download" })), options); return exports.api_url("generate_archive", options) + "?" + hashToQuery(cloudinary_params); } @@ -1020,7 +1020,7 @@ function download_archive_url(options = {}) { function download_zip_url(options = {}) { return exports.download_archive_url(merge(options, { - target_format: "zip", + target_format: "zip" })); } @@ -1031,7 +1031,7 @@ function download_folder(folder_path, options = {}) { options.resource_type = options.resource_type || "all"; options.prefixes = folder_path; let cloudinary_params = exports.sign_request(exports.archive_params(merge(options, { - mode: "download", + mode: "download" })), options); return exports.api_url("generate_archive", options) + "?" + hashToQuery(cloudinary_params); } @@ -1210,7 +1210,7 @@ function archive_params(options = {}) { transformations: utils.build_eager(options.transformations), type: options.type, use_original_filename: exports.as_safe_bool(options.use_original_filename), - folder_path: options.folder_path, + folder_path: options.folder_path }; } @@ -1241,7 +1241,7 @@ function generate_responsive_breakpoints_string(breakpoints) { if (breakpoint_settings != null) { if (breakpoint_settings.transformation) { breakpoint_settings.transformation = utils.generate_transformation_string( - clone(breakpoint_settings.transformation), + clone(breakpoint_settings.transformation) ); } } @@ -1254,8 +1254,8 @@ function build_streaming_profiles_param(options = {}) { if (isArray(params.representations)) { params.representations = JSON.stringify(params.representations.map( r => ({ - transformation: utils.generate_transformation_string(r.transformation), - }), + transformation: utils.generate_transformation_string(r.transformation) + }) )); } return params; @@ -1282,7 +1282,7 @@ function hashToParameters(hash) { */ function hashToQuery(hash) { return hashToParameters(hash).map( - ([key, value]) => `${querystring.escape(key)}=${querystring.escape(value)}`, + ([key, value]) => `${querystring.escape(key)}=${querystring.escape(value)}` ).join('&'); } @@ -1414,5 +1414,5 @@ Object.assign(module.exports, { isString, isUndefined, keys: source => Object.keys(source), - ensurePresenceOf, + ensurePresenceOf }); diff --git a/lib/utils/srcsetUtils.js b/lib/utils/srcsetUtils.js index 241379ec..2d55ac5d 100644 --- a/lib/utils/srcsetUtils.js +++ b/lib/utils/srcsetUtils.js @@ -152,5 +152,5 @@ module.exports = { generateSrcsetAttribute, generateSizesAttribute, generateMediaAttr, - generateImageResponsiveAttributes, + generateImageResponsiveAttributes }; diff --git a/lib/v2/api.js b/lib/v2/api.js index 9e5125b4..d4f404b6 100644 --- a/lib/v2/api.js +++ b/lib/v2/api.js @@ -58,5 +58,5 @@ v1_adapters(exports, api, { update_metadata_field: 2, update_metadata_field_datasource: 2, delete_datasource_entries: 2, - restore_metadata_field_datasource: 2, + restore_metadata_field_datasource: 2 }); diff --git a/lib/v2/index.js b/lib/v2/index.js index 9571a0aa..997cf879 100644 --- a/lib/v2/index.js +++ b/lib/v2/index.js @@ -7,6 +7,6 @@ const v2 = { ...v1, api, uploader, - search, + search }; module.exports = v2; diff --git a/lib/v2/search.js b/lib/v2/search.js index 50b55442..16efbb7b 100644 --- a/lib/v2/search.js +++ b/lib/v2/search.js @@ -6,7 +6,7 @@ const Search = class Search { this.query_hash = { sort_by: [], aggregate: [], - with_field: [], + with_field: [] }; } diff --git a/lib/v2/uploader.js b/lib/v2/uploader.js index 84386b69..7f931cb9 100644 --- a/lib/v2/uploader.js +++ b/lib/v2/uploader.js @@ -25,7 +25,7 @@ v1_adapters(exports, uploader, { replace_tag: 2, create_archive: 0, create_zip: 0, - update_metadata: 2, + update_metadata: 2 }); exports.direct_upload = uploader.direct_upload; diff --git a/samples/basic/basic.js b/samples/basic/basic.js index 61631a78..439fd651 100644 --- a/samples/basic/basic.js +++ b/samples/basic/basic.js @@ -69,7 +69,7 @@ cloudinary.uploader.upload('pizza.jpg', { tags: 'basic_sample', public_id: 'my_f // Eager Transformations: // Applied as soon as the file is uploaded, instead of lazily applying them when accessed by your site's visitors. var eager_options = { - width: 200, height: 150, crop: 'scale', format: 'jpg', + width: 200, height: 150, crop: 'scale', format: 'jpg' }; cloudinary.uploader.upload("lake.jpg", { tags: "basic_sample", public_id: "blue_lake", eager: eager_options }, function (err, image) { // "eager" parameter accepts a hash (or just a single item). You can pass diff --git a/samples/photo_album/config/schema.js b/samples/photo_album/config/schema.js index 58b5792a..fe1709e4 100644 --- a/samples/photo_album/config/schema.js +++ b/samples/photo_album/config/schema.js @@ -7,7 +7,7 @@ var schema = new Schema('memory'); // Define models schema.define('Photo', { title: { type: String, length: 255 }, - image: { type: JSON }, + image: { type: JSON } }); module.exports = schema; diff --git a/samples/photo_album/controllers/photos_controller.js b/samples/photo_album/controllers/photos_controller.js index 35e4aca5..376eabcf 100644 --- a/samples/photo_album/controllers/photos_controller.js +++ b/samples/photo_album/controllers/photos_controller.js @@ -21,7 +21,7 @@ function add_through_server(req, res) { }) .finally(function () { res.render('photos/add', { - photo: photo, + photo: photo }); }); } @@ -69,7 +69,7 @@ function add_direct(req, res) { .finally(function () { res.render('photos/add_direct', { photo: photo, - cloudinary_cors: cloudinary_cors, + cloudinary_cors: cloudinary_cors }); }); } @@ -107,7 +107,7 @@ function add_direct_unsigned(req, res) { unsigned: true, name: preset_name, folder: "preset_folder", - return_delete_token: true, + return_delete_token: true }); }) .finally(function (preset) { @@ -115,7 +115,7 @@ function add_direct_unsigned(req, res) { { photo: photo, cloudinary_cors: cloudinary_cors, - preset_name: preset_name, + preset_name: preset_name }); }); } diff --git a/samples/photo_album/server.js b/samples/photo_album/server.js index 28818696..1c3e9520 100644 --- a/samples/photo_album/server.js +++ b/samples/photo_album/server.js @@ -76,7 +76,7 @@ app.use(function (req, res, next) { console.log('error (404)'); res.status(404).render('errors/404', { url: req.url, - error: 'Not found', + error: 'Not found' }); }); diff --git a/test/access_control_spec.js b/test/access_control_spec.js index bfa281a2..ea7b36a0 100644 --- a/test/access_control_spec.js +++ b/test/access_control_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require("expect.js"); @@ -11,12 +11,12 @@ const build_upload_params = cloudinary.utils.build_upload_params; const ACL = { access_type: 'anonymous', start: new Date(Date.UTC(2019, 1, 22, 16, 20, 57)), - end: '2019-03-22 00:00 +0200', + end: '2019-03-22 00:00 +0200' }; const ACL_2 = { access_type: 'anonymous', start: '2019-02-22 16:20:57Z', - end: '2019-03-22 00:00 +0200', + end: '2019-03-22 00:00 +0200' }; const ACL_STRING = '{"access_type":"anonymous","start":"2019-02-22 16:20:57 +0200","end":"2019-03-22 00:00 +0200"}'; @@ -30,7 +30,7 @@ describe("Access Control", function () { describe("build_upload_params", function () { it("should accept a Hash value", function () { let params = build_upload_params({ - access_control: ACL, + access_control: ACL }); expect(params).to.have.key('access_control'); expect(isString(params.access_control)).to.be.ok(); @@ -38,7 +38,7 @@ describe("Access Control", function () { }); it("should accept an array of Hash values", function () { let params = build_upload_params({ - access_control: [ACL, ACL_2], + access_control: [ACL, ACL_2] }); expect(params).to.have.key('access_control'); expect(isString(params.access_control)).to.be.ok(); @@ -51,7 +51,7 @@ describe("Access Control", function () { }); it("should accept a JSON string", function () { let params = build_upload_params({ - access_control: ACL_STRING, + access_control: ACL_STRING }); expect(params).to.have.key('access_control'); expect(isString(params.access_control)).to.be.ok(); diff --git a/test/archivespec.js b/test/archivespec.js index 8bddea4f..6c97f8e6 100644 --- a/test/archivespec.js +++ b/test/archivespec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const https = require('https'); @@ -18,17 +18,17 @@ const testConstants = require('./testUtils/testConstants'); const { TIMEOUT, TAGS, - URLS, + URLS } = testConstants; const { TEST_TAG, - UPLOAD_TAGS, + UPLOAD_TAGS } = TAGS; const { VIDEO_URL, - IMAGE_URL, + IMAGE_URL } = URLS; const { utils, api, uploader } = cloudinary.v2; @@ -57,29 +57,29 @@ sharedExamples('archive', function () { public_id: PUBLIC_ID1, tags: UPLOAD_TAGS.concat([ARCHIVE_TAG]), transformation: { - effect: "blackwhite", - }, + effect: "blackwhite" + } }), uploader.upload(IMAGE_URL, { public_id: PUBLIC_ID2, tags: UPLOAD_TAGS.concat([ARCHIVE_TAG]), transformation: { - effect: "blackwhite", - }, + effect: "blackwhite" + } }), uploader.upload(IMAGE_URL, { public_id: PUBLIC_ID_RAW, resource_type: "raw", - tags: UPLOAD_TAGS.concat([ARCHIVE_TAG]), + tags: UPLOAD_TAGS.concat([ARCHIVE_TAG]) }), uploader.upload(VIDEO_URL, { public_id: "dog", resource_type: "video", - tags: UPLOAD_TAGS.concat([ARCHIVE_TAG]), - }), + tags: UPLOAD_TAGS.concat([ARCHIVE_TAG]) + }) ]); }); after(function () { @@ -101,7 +101,7 @@ describe("archive", function () { target_public_id: 'gem_archive_test', public_ids: [PUBLIC_ID2, PUBLIC_ID1], target_tags: ARCHIVE_TAG, - expires_at: Date.now() / 1000 + 60, // expiration after 60 seconds + expires_at: Date.now() / 1000 + 60 // expiration after 60 seconds }); }); describe('public_ids', function () { @@ -147,7 +147,7 @@ describe("archive", function () { public_ids: [PUBLIC_ID2, PUBLIC_ID1], target_tags: [TEST_TAG, ARCHIVE_TAG], mode: 'create', - skip_transformation_name: true, + skip_transformation_name: true }).then((result) => { archive_result = result; }); @@ -168,7 +168,7 @@ describe("archive", function () { tags: TEST_TAG, public_ids: [PUBLIC_ID_RAW, "non-existing-resource"], resource_type: "raw", - allow_missing: true, + allow_missing: true }); sinon.assert.calledWith(write, sinon.match(helper.uploadParamMatcher("tags[]", TEST_TAG))); sinon.assert.calledWith(write, sinon.match(helper.uploadParamMatcher("public_ids[]", PUBLIC_ID_RAW))); @@ -180,7 +180,7 @@ describe("archive", function () { it('should create archive with "zip" format and include multiple resource types', function () { return uploader.create_zip({ fully_qualified_public_ids: [FULLY_QUALIFIED_IMAGE, FULLY_QUALIFIED_VIDEO], - resource_type: "auto", + resource_type: "auto" }).then((result) => { expect(result.file_count).to.eql(2); }); diff --git a/test/cache_spec.js b/test/cache_spec.js index 9d714e07..de772ece 100644 --- a/test/cache_spec.js +++ b/test/cache_spec.js @@ -16,14 +16,14 @@ const testConstants = require('./testUtils/testConstants'); const { TIMEOUT, - TAGS, + TAGS } = testConstants; const UPLOAD_TAGS = TAGS.UPLOAD_TAGS; const TRANSFORMATION_1 = { angle: 45, - crop: 'scale', + crop: 'scale' }; const FORMAT_1 = 'png'; @@ -48,17 +48,17 @@ describe("Cache", function () { { create_derived: false, transformation: { angle: 90 }, - format: 'gif', + format: 'gif' }, { create_derived: false, transformation: TRANSFORMATION_1, - format: FORMAT_1, + format: FORMAT_1 }, { - create_derived: false, - }, - ], + create_derived: false + } + ] }; }); after(function () { @@ -82,7 +82,7 @@ describe("Cache", function () { type, resource_type, raw_transformation: bp.transformation, - format: path.extname(bp.breakpoints[0].url).slice(1), + format: path.extname(bp.breakpoints[0].url).slice(1) }); expect(cachedBp).to.eql(bp.breakpoints.map(i => i.width)); }); diff --git a/test/cloudinary_spec.js b/test/cloudinary_spec.js index 9cf10b7a..e89a7244 100644 --- a/test/cloudinary_spec.js +++ b/test/cloudinary_spec.js @@ -8,7 +8,7 @@ describe("cloudinary", function () { cloud_name: "test123", api_key: 'a', api_secret: 'b', - responsive_width_transformation: null, + responsive_width_transformation: null })); }); it("should use cloud_name from config", function () { @@ -18,7 +18,7 @@ describe("cloudinary", function () { it("should allow overriding cloud_name in options", function () { var options, result; options = { - cloud_name: "test321", + cloud_name: "test321" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -27,7 +27,7 @@ describe("cloudinary", function () { it("should use format from options", function () { var options, result; options = { - format: "jpg", + format: "jpg" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -36,7 +36,7 @@ describe("cloudinary", function () { it("should use default secure distribution if secure=true", function () { var options, result; options = { - secure: true, + secure: true }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -46,7 +46,7 @@ describe("cloudinary", function () { var options, result; options = { secure: true, - private_cdn: true, + private_cdn: true }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -57,7 +57,7 @@ describe("cloudinary", function () { options = { secure: true, private_cdn: true, - secure_distribution: "something.cloudfront.net", + secure_distribution: "something.cloudfront.net" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -66,7 +66,7 @@ describe("cloudinary", function () { it("should not add cloud_name if private_cdn and not secure", function () { var options, result; options = { - private_cdn: true, + private_cdn: true }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -76,23 +76,23 @@ describe("cloudinary", function () { var options, result; options = { width: 100, - height: 100, + height: 100 }; result = cloudinary.utils.url("test", options); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/h_100,w_100/test"); expect(options).to.eql({ width: 100, - height: 100, + height: 100 }); options = { width: 100, height: 100, - crop: "crop", + crop: "crop" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({ width: 100, - height: 100, + height: 100 }); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/test"); }); @@ -101,7 +101,7 @@ describe("cloudinary", function () { options = { width: 100, height: 100, - crop: "limit", + crop: "limit" }; result = cloudinary.utils.url("test", options); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/c_limit,h_100,w_100/test"); @@ -109,7 +109,7 @@ describe("cloudinary", function () { options = { width: 100, height: 100, - crop: "fit", + crop: "fit" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -121,7 +121,7 @@ describe("cloudinary", function () { width: 100, height: 100, crop: "scale", - angle: "auto", + angle: "auto" }; result = cloudinary.utils.url("test", options); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/a_auto,c_scale,h_100,w_100/test"); @@ -136,7 +136,7 @@ describe("cloudinary", function () { gravity: "center", quality: 0.4, prefix: "a", - opacity: 20, + opacity: 20 }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -151,7 +151,7 @@ describe("cloudinary", function () { radius: 3, gravity: "center", quality: 80, - prefix: "a", + prefix: "a" })).to.eql(`${upload_path}/g_center,p_a,q_80,r_3,x_1,y_2/test`); expect(cloudinary.utils.url("test", { x: 1, @@ -159,7 +159,7 @@ describe("cloudinary", function () { radius: 3, gravity: "center", quality: "80:444", - prefix: "a", + prefix: "a" })).to.eql(`${upload_path}/g_center,p_a,q_80:444,r_3,x_1,y_2/test`); }); it("should support auto value", function () { @@ -169,7 +169,7 @@ describe("cloudinary", function () { radius: 3, gravity: "center", quality: "auto", - prefix: "a", + prefix: "a" })).to.eql(`${upload_path}/g_center,p_a,q_auto,r_3,x_1,y_2/test`); expect(cloudinary.utils.url("test", { x: 1, @@ -177,7 +177,7 @@ describe("cloudinary", function () { radius: 3, gravity: "center", quality: "auto:good", - prefix: "a", + prefix: "a" })).to.eql(`${upload_path}/g_center,p_a,q_auto:good,r_3,x_1,y_2/test`); }); }); @@ -192,7 +192,7 @@ describe("cloudinary", function () { })).to.eql(`${upload_path}/r_10/test`); expect(cloudinary.utils.url("test", { variables: [['$v', 10]], - radius: '$v', + radius: '$v' })).to.eql(`${upload_path}/$v_10,r_$v/test`); }); it("should support an array of values", function() { @@ -201,11 +201,11 @@ describe("cloudinary", function () { })).to.eql(`${upload_path}/r_10:20:30/test`); expect(cloudinary.utils.url("test", { variables: [['$v', 10]], - radius: [10, 20, '$v'], + radius: [10, 20, '$v'] })).to.eql(`${upload_path}/$v_10,r_10:20:$v/test`); expect(cloudinary.utils.url("test", { variables: [['$v', 10]], - radius: [10, 20, '$v', 40], + radius: [10, 20, '$v', 40] })).to.eql(`${upload_path}/$v_10,r_10:20:$v:40/test`); }) it("should support colon separated values", function() { @@ -221,7 +221,7 @@ describe("cloudinary", function () { it("should support named transformation", function() { var options, result; options = { - transformation: "blip", + transformation: "blip" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -230,7 +230,7 @@ describe("cloudinary", function () { it("should support array of named transformations", function () { var options, result; options = { - transformation: ["blip", "blop"], + transformation: ["blip", "blop"] }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -242,14 +242,14 @@ describe("cloudinary", function () { transformation: { x: 100, y: 100, - crop: "fill", + crop: "fill" }, crop: "crop", - width: 100, + width: 100 }; result = cloudinary.utils.url("test", options); expect(options).to.eql({ - width: 100, + width: 100 }); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/c_fill,x_100,y_100/c_crop,w_100/test"); }); @@ -261,18 +261,18 @@ describe("cloudinary", function () { x: 100, y: 100, width: 200, - crop: "fill", + crop: "fill" }, { - radius: 10, - }, + radius: 10 + } ], crop: "crop", - width: 100, + width: 100 }; result = cloudinary.utils.url("test", options); expect(options).to.eql({ - width: 100, + width: 100 }); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/c_fill,w_200,x_100,y_100/r_10/c_crop,w_100/test"); }); @@ -284,10 +284,10 @@ describe("cloudinary", function () { { x: 100, y: 100, - crop: "fill", + crop: "fill" }, - {}, - ], + {} + ] }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -297,19 +297,19 @@ describe("cloudinary", function () { var options, result; options = { size: "10x10", - crop: "crop", + crop: "crop" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({ width: "10", - height: "10", + height: "10" }); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/c_crop,h_10,w_10/test"); }); it("should use type from options", function () { var options, result; options = { - type: "facebook", + type: "facebook" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -318,7 +318,7 @@ describe("cloudinary", function () { it("should use resource_type from options", function () { var options, result; options = { - resource_type: "raw", + resource_type: "raw" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -327,13 +327,13 @@ describe("cloudinary", function () { it("should ignore http links only if type is not given ", function () { var options, result; options = { - type: null, + type: null }; result = cloudinary.utils.url("http://example.com/", options); expect(options).to.eql({}); expect(result).to.eql("http://example.com/"); options = { - type: "fetch", + type: "fetch" }; result = cloudinary.utils.url("http://example.com/", options); expect(options).to.eql({}); @@ -342,7 +342,7 @@ describe("cloudinary", function () { it("should escape fetch urls", function () { var options, result; options = { - type: "fetch", + type: "fetch" }; result = cloudinary.utils.url("http://blah.com/hello?a=b", options); expect(options).to.eql({}); @@ -351,7 +351,7 @@ describe("cloudinary", function () { it("should escape http urls", function () { var options, result; options = { - type: "youtube", + type: "youtube" }; result = cloudinary.utils.url("http://www.youtube.com/watch?v=d9NF2edxy-M", options); expect(options).to.eql({}); @@ -360,13 +360,13 @@ describe("cloudinary", function () { it("should support background", function () { var options, result; options = { - background: "red", + background: "red" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/b_red/test"); options = { - background: "#112233", + background: "#112233" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -375,7 +375,7 @@ describe("cloudinary", function () { it("should support default_image", function () { var options, result; options = { - default_image: "default", + default_image: "default" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -384,7 +384,7 @@ describe("cloudinary", function () { it("should support angle", function () { var options, result; options = { - angle: 12, + angle: 12 }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -394,7 +394,7 @@ describe("cloudinary", function () { var options, result; options = { format: "jpg", - type: "fetch", + type: "fetch" }; result = cloudinary.utils.url("http://cloudinary.com/images/logo.png", options); expect(options).to.eql({}); @@ -403,7 +403,7 @@ describe("cloudinary", function () { it("should support effect", function () { var options, result; options = { - effect: "sepia", + effect: "sepia" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -412,7 +412,7 @@ describe("cloudinary", function () { it("should support effect with param", function () { var options, result; options = { - effect: ["sepia", 10], + effect: ["sepia", 10] }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -420,7 +420,7 @@ describe("cloudinary", function () { }); [ ["overlay", "l"], - ["underlay", "u"], + ["underlay", "u"] ].forEach(([layer, short]) => { it(`should support ${layer}`, function () { var result; @@ -434,7 +434,7 @@ describe("cloudinary", function () { var options, result; options = { height: 100, - width: 100, + width: 100 }; options[layer] = "text:hello"; result = cloudinary.utils.url("test", options); @@ -447,7 +447,7 @@ describe("cloudinary", function () { hello: null, goodbye: 12, world: "problem", - undef: void 0, + undef: void 0 }, "1234")).to.eql("f05cfe85cee78e7e997b3c7da47ba212dcbf1ea5"); }); it("should correctly build signed preloaded image", function () { @@ -456,13 +456,13 @@ describe("cloudinary", function () { version: 1251251251, public_id: "abcd", format: "jpg", - signature: "123515adfa151", + signature: "123515adfa151" })).to.eql("image/upload/v1251251251/abcd.jpg#123515adfa151"); }); it('should support custom function of type wasm with a source', function () { var options, result; options = { - custom_function: { function_type: 'wasm', source: 'blur.wasm' }, + custom_function: { function_type: 'wasm', source: 'blur.wasm' } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -471,7 +471,7 @@ describe("cloudinary", function () { it('should support arbitrary custom function types', function () { var options, result; options = { - custom_function: { function_type: 'amazing', source: 'awesome' }, + custom_function: { function_type: 'amazing', source: 'awesome' } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -480,7 +480,7 @@ describe("cloudinary", function () { it('should support custom function with no source', function () { var options, result; options = { - custom_function: { function_type: 'wasm' }, + custom_function: { function_type: 'wasm' } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -489,7 +489,7 @@ describe("cloudinary", function () { it('should support custom function with no function_type', function () { var options, result; options = { - custom_function: { source: 'blur.wasm' }, + custom_function: { source: 'blur.wasm' } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -498,7 +498,7 @@ describe("cloudinary", function () { it('should support custom function that is not an object', function () { var options, result; options = { - custom_function: [], + custom_function: [] }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -507,7 +507,7 @@ describe("cloudinary", function () { it('should support custom function with no function_type or source', function () { var options, result; options = { - custom_function: {}, + custom_function: {} }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -519,8 +519,8 @@ describe("cloudinary", function () { custom_function: { function_type: 'remote', source: - 'https://df34ra4a.execute-api.us-west-2.amazonaws.com/default/cloudinaryFunction', - }, + 'https://df34ra4a.execute-api.us-west-2.amazonaws.com/default/cloudinaryFunction' + } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -529,7 +529,7 @@ describe("cloudinary", function () { it('should should not include custom function with undefined value', function () { var options, result; options = { - custom_function: undefined, + custom_function: undefined }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -541,8 +541,8 @@ describe("cloudinary", function () { custom_pre_function: { function_type: 'remote', source: - 'https://df34ra4a.execute-api.us-west-2.amazonaws.com/default/cloudinaryFunction', - }, + 'https://df34ra4a.execute-api.us-west-2.amazonaws.com/default/cloudinaryFunction' + } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -551,7 +551,7 @@ describe("cloudinary", function () { it('should support custom pre function with no function_type or source', function () { var options, result; options = { - custom_pre_function: {}, + custom_pre_function: {} }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -560,7 +560,7 @@ describe("cloudinary", function () { it("should support density", function () { var options, result; options = { - density: 150, + density: 150 }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -569,7 +569,7 @@ describe("cloudinary", function () { it("should support page", function () { var options, result; options = { - page: 5, + page: 5 }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -578,7 +578,7 @@ describe("cloudinary", function () { it("should support external cname", function () { var options, result; options = { - cname: "hello.com", + cname: "hello.com" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -588,7 +588,7 @@ describe("cloudinary", function () { var options, result; options = { cname: "hello.com", - cdn_subdomain: true, + cdn_subdomain: true }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -598,8 +598,8 @@ describe("cloudinary", function () { var options, result; options = { border: { - width: 5, - }, + width: 5 + } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -607,14 +607,14 @@ describe("cloudinary", function () { options = { border: { width: 5, - color: "#ffaabbdd", - }, + color: "#ffaabbdd" + } }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/bo_5px_solid_rgb:ffaabbdd/test"); options = { - border: "1px_solid_blue", + border: "1px_solid_blue" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -623,13 +623,13 @@ describe("cloudinary", function () { it("should support flags", function () { var options, result; options = { - flags: "abc", + flags: "abc" }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/fl_abc/test"); options = { - flags: ["abc", "def"], + flags: ["abc", "def"] }; result = cloudinary.utils.url("test", options); expect(options).to.eql({}); @@ -639,7 +639,7 @@ describe("cloudinary", function () { var result = cloudinary.utils.url("folder/test"); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/v1/folder/test"); result = cloudinary.utils.url("folder/test", { - version: 123, + version: 123 }); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/v123/folder/test"); }); @@ -649,7 +649,7 @@ describe("cloudinary", function () { }); it("should allow to shorted image/upload urls", function () { var result = cloudinary.utils.url("test", { - shorten: true, + shorten: true }); expect(result).to.eql("http://res.cloudinary.com/test123/iu/test"); }); @@ -660,7 +660,7 @@ describe("cloudinary", function () { ["a+b", "a%2Bb"], ["a%20b", "a%20b"], ["a-b", "a-b"], - ["a??b", "a%3F%3Fb"], + ["a??b", "a%3F%3Fb"] ]; tests.forEach(([source, target]) => { let result = cloudinary.utils.url(source); @@ -675,13 +675,13 @@ describe("cloudinary", function () { crop: "crop", width: 10, height: 20, - sign_url: true, + sign_url: true }); expect(actual).to.eql(expected); expected = "http://res.cloudinary.com/test123/image/upload/s----SjmNDA--/v1234/image.jpg"; actual = cloudinary.utils.url("image.jpg", { version: 1234, - sign_url: true, + sign_url: true }); expect(actual).to.eql(expected); expected = "http://res.cloudinary.com/test123/image/upload/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg"; @@ -689,51 +689,51 @@ describe("cloudinary", function () { crop: "crop", width: 10, height: 20, - sign_url: true, + sign_url: true }); expect(actual).to.eql(expected); }); it("should correctly sign_request", function () { var params = cloudinary.utils.sign_request({ public_id: "folder/file", - version: "1234", + version: "1234" }, { api_key: '1234', - api_secret: 'b', + api_secret: 'b' }); expect(params).to.eql({ public_id: "folder/file", version: "1234", signature: "7a3349cbb373e4812118d625047ede50b90e7b67", - api_key: "1234", + api_key: "1234" }); }); it("should correctly process_request_params", function () { var params = cloudinary.utils.process_request_params({ public_id: "folder/file", version: "1234", - colors: void 0, + colors: void 0 }, { api_key: '1234', api_secret: 'b', - unsigned: true, + unsigned: true }); expect(params).to.eql({ public_id: "folder/file", - version: "1234", + version: "1234" }); params = cloudinary.utils.process_request_params({ public_id: "folder/file", - version: "1234", + version: "1234" }, { api_key: '1234', - api_secret: 'b', + api_secret: 'b' }); expect(params).to.eql({ public_id: "folder/file", version: "1234", signature: "7a3349cbb373e4812118d625047ede50b90e7b67", - api_key: "1234", + api_key: "1234" }); }); it("should support preloaded identifier format", function () { @@ -741,7 +741,7 @@ describe("cloudinary", function () { expect(result).to.eql("http://res.cloudinary.com/test123/raw/private/v123456/document.docx"); result = cloudinary.utils.url("image/private/v123456/img.jpg", { crop: "scale", - width: "1.0", + width: "1.0" }); expect(result).to.eql("http://res.cloudinary.com/test123/image/private/c_scale,w_1.0/v123456/img.jpg"); }); @@ -751,36 +751,36 @@ describe("cloudinary", function () { width: 100, height: 100, crop: "crop", - responsive_width: true, + responsive_width: true }; result = cloudinary.utils.url("test", options); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/c_limit,w_auto/test"); expect(options).to.eql({ - responsive: true, + responsive: true }); cloudinary.config({ responsive_width_transformation: { width: "auto", - crop: "pad", - }, + crop: "pad" + } }); options = { width: 100, height: 100, crop: "crop", - responsive_width: true, + responsive_width: true }; result = cloudinary.utils.url("test", options); expect(result).to.eql("http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/c_pad,w_auto/test"); expect(options).to.eql({ - responsive: true, + responsive: true }); }); it("should generate urls with a 32 character signature when both sign_url and long_url_signature are true", function () { var options, result; options = { sign_url: true, - long_url_signature: true, + long_url_signature: true }; result = cloudinary.utils.url("sample.jpg", options); expect(result).to.eql('http://res.cloudinary.com/test123/image/upload/s--2hbrSMPOjj5BJ4xV7SgFbRDevFaQNUFf--/sample.jpg'); @@ -788,7 +788,7 @@ describe("cloudinary", function () { it("should generate urls with a 8 character signature when sign_url is true", function () { var options, result; options = { - sign_url: true, + sign_url: true }; result = cloudinary.utils.url("sample.jpg", options); expect(result).to.eql('http://res.cloudinary.com/test123/image/upload/s--v2fTPYTu--/sample.jpg'); diff --git a/test/integration/api/admin/api_spec.js b/test/integration/api/admin/api_spec.js index 86a13a0f..ad84316f 100644 --- a/test/integration/api/admin/api_spec.js +++ b/test/integration/api/admin/api_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require("expect.js"); @@ -25,7 +25,7 @@ const { PRESETS, TRANSFORMATIONS, PUBLIC_ID_PREFIX, - UNIQUE_TEST_FOLDER, + UNIQUE_TEST_FOLDER } = testConstants; const { @@ -38,38 +38,38 @@ const { PUBLIC_ID_6, PUBLIC_ID_BACKUP_1, PUBLIC_ID_BACKUP_2, - PUBLIC_ID_BACKUP_3, + PUBLIC_ID_BACKUP_3 } = PUBLIC_IDS; const { TEST_TAG, SDK_TAG, - UPLOAD_TAGS, + UPLOAD_TAGS } = TAGS; const { NAMED_TRANSFORMATION, NAMED_TRANSFORMATION2, EXPLICIT_TRANSFORMATION_NAME, - EXPLICIT_TRANSFORMATION_NAME2, + EXPLICIT_TRANSFORMATION_NAME2 } = TRANSFORMATIONS; const { API_TEST_UPLOAD_PRESET1, API_TEST_UPLOAD_PRESET2, API_TEST_UPLOAD_PRESET3, - API_TEST_UPLOAD_PRESET4, + API_TEST_UPLOAD_PRESET4 } = PRESETS; const EXPLICIT_TRANSFORMATION = { width: 100, crop: "scale", - overlay: `text:Arial_60:${TEST_TAG}`, + overlay: `text:Arial_60:${TEST_TAG}` }; const EXPLICIT_TRANSFORMATION2 = { width: 200, crop: "scale", - overlay: `text:Arial_60:${TEST_TAG}`, + overlay: `text:Arial_60:${TEST_TAG}` }; @@ -78,13 +78,13 @@ sharedExamples("a list with a cursor", function (testFunc, ...args) { specify(":max_results", function () { return helper.mockPromise(function (xhr, writeSpy, requestSpy) { testFunc(...args, { - max_results: 10, + max_results: 10 }); if (writeSpy.called) { sinon.assert.calledWith(writeSpy, sinon.match(/max_results=10/)); } else { sinon.assert.calledWith(requestSpy, sinon.match({ - query: sinon.match(/max_results=10/), + query: sinon.match(/max_results=10/) })); } }); @@ -92,13 +92,13 @@ sharedExamples("a list with a cursor", function (testFunc, ...args) { specify(":next_cursor", function () { return helper.mockPromise(function (xhr, writeSpy, requestSpy) { testFunc(...args, { - next_cursor: 23452342, + next_cursor: 23452342 }); if (writeSpy.called) { sinon.assert.calledWith(writeSpy, sinon.match(/next_cursor=23452342/)); } else { sinon.assert.calledWith(requestSpy, sinon.match({ - query: sinon.match(/next_cursor=23452342/), + query: sinon.match(/next_cursor=23452342/) })); } }); @@ -122,13 +122,13 @@ sharedExamples("accepts next_cursor", function (testFunc, ...args) { }); specify(":next_cursor", function () { testFunc(...args, { - next_cursor: 23452342, + next_cursor: 23452342 }); if (writeSpy.called) { sinon.assert.calledWith(writeSpy, sinon.match(/next_cursor=23452342/)); } else { sinon.assert.calledWith(requestSpy, sinon.match({ - query: sinon.match(/next_cursor=23452342/), + query: sinon.match(/next_cursor=23452342/) })); } }); @@ -161,26 +161,26 @@ describe("api", function () { public_id: PUBLIC_ID, tags: UPLOAD_TAGS, context: "key=value", - eager: [EXPLICIT_TRANSFORMATION], + eager: [EXPLICIT_TRANSFORMATION] }), uploadImage({ public_id: PUBLIC_ID_2, tags: UPLOAD_TAGS, context: "key=value", - eager: [EXPLICIT_TRANSFORMATION], + eager: [EXPLICIT_TRANSFORMATION] }), uploadImage({ public_id: PUBLIC_ID_5, tags: UPLOAD_TAGS, context: `${contextKey}=test`, - eager: [EXPLICIT_TRANSFORMATION], + eager: [EXPLICIT_TRANSFORMATION] }), uploadImage({ public_id: PUBLIC_ID_6, tags: UPLOAD_TAGS, context: `${contextKey}=alt-test`, - eager: [EXPLICIT_TRANSFORMATION], - }), + eager: [EXPLICIT_TRANSFORMATION] + }) ]).finally(function () {}); }); after(function () { @@ -197,7 +197,7 @@ describe("api", function () { cloudinary.v2.api.delete_upload_preset(API_TEST_UPLOAD_PRESET1), cloudinary.v2.api.delete_upload_preset(API_TEST_UPLOAD_PRESET2), cloudinary.v2.api.delete_upload_preset(API_TEST_UPLOAD_PRESET3), - cloudinary.v2.api.delete_upload_preset(API_TEST_UPLOAD_PRESET4), + cloudinary.v2.api.delete_upload_preset(API_TEST_UPLOAD_PRESET4) ]); }); @@ -214,7 +214,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); publicId = ''; return uploadImage({ - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { publicId = result.public_id; return cloudinary.v2.api.resources(); @@ -227,7 +227,7 @@ describe("api", function () { it("should allow listing resources by type", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage({ - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then( ({ public_id }) => cloudinary.v2.api.resources({ type: "upload" }) .then(result => [public_id, result]) @@ -242,7 +242,7 @@ describe("api", function () { return cloudinary.v2.api.resources({ type: "upload", prefix: PUBLIC_ID_PREFIX, - max_results: 500, + max_results: 500 }).then(function (result) { let public_ids = result.resources.map(resource => resource.public_id); @@ -257,7 +257,7 @@ describe("api", function () { return cloudinary.v2.api.resources_by_tag(TEST_TAG, { context: true, tags: true, - max_results: 500, + max_results: 500 }).then((result) => { expect(result.resources.map(e => e.public_id)) .to.contain(PUBLIC_ID).and.contain(PUBLIC_ID_2); @@ -281,7 +281,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.api.resources_by_ids([PUBLIC_ID, PUBLIC_ID_2], { context: true, - tags: true, + tags: true }).then((result) => { expect(result.resources.map(e => e.public_id).sort()).to.eql([PUBLIC_ID, PUBLIC_ID_2]); expect(getAllTags(result)).to.contain(TEST_TAG); @@ -294,16 +294,16 @@ describe("api", function () { cloudinary.v2.api.resources_by_tag(TEST_TAG, { type: "upload", max_results: 500, - direction: "asc", + direction: "asc" }), cloudinary.v2.api.resources_by_tag(TEST_TAG, { type: "upload", max_results: 500, - direction: "desc", + direction: "desc" }) ).then(([resultAsc, resultDesc]) => [ resultAsc.resources.map(r => r.public_id), - resultDesc.resources.map(r => r.public_id), + resultDesc.resources.map(r => r.public_id) ]).then(([asc, desc]) => expect(asc.reverse()).to.eql(desc)); }); it("should allow listing resources by start_at", function () { @@ -312,10 +312,10 @@ describe("api", function () { cloudinary.v2.api.resources({ type: "upload", start_at: start_at, - direction: "asc", + direction: "asc" }); sinon.assert.calledWith(requestSpy, sinon.match({ - query: sinon.match(`start_at=${encodeURIComponent(start_at)}`), + query: sinon.match(`start_at=${encodeURIComponent(start_at)}`) })); }); }); @@ -323,7 +323,7 @@ describe("api", function () { this.timeout(TIMEOUT.LONG); return uploadImage({ tags: UPLOAD_TAGS, - eager: [EXPLICIT_TRANSFORMATION], + eager: [EXPLICIT_TRANSFORMATION] }).then(({ public_id }) => cloudinary.v2.api.resource(public_id) .then(resource => [public_id, resource])) .then(([public_id, resource]) => { @@ -360,7 +360,7 @@ describe("api", function () { const publicId = "api_test_backup" + UNIQUE_JOB_SUFFIX_ID; before(() => uploadImage({ public_id: publicId, - backup: true, + backup: true }).then(() => cloudinary.v2.api.resource(publicId)).then((resource) => { expect(resource).not.to.be(null); })); @@ -391,9 +391,9 @@ describe("api", function () { eager: [ { width: 101, - crop: "scale", - }, - ], + crop: "scale" + } + ] }).then(wait(2000)).then( ({ public_id }) => cloudinary.v2.api.resource(public_id) .then(resource => [public_id, resource]) @@ -417,18 +417,18 @@ describe("api", function () { uploadImage({ public_id: PUBLIC_ID_1, tags: UPLOAD_TAGS, - eager: [EXPLICIT_TRANSFORMATION], + eager: [EXPLICIT_TRANSFORMATION] }), uploadImage({ public_id: PUBLIC_ID_2, tags: UPLOAD_TAGS, - eager: [EXPLICIT_TRANSFORMATION2], + eager: [EXPLICIT_TRANSFORMATION2] }), uploadImage({ public_id: PUBLIC_ID_3, tags: UPLOAD_TAGS, - eager: [EXPLICIT_TRANSFORMATION, EXPLICIT_TRANSFORMATION2], - }), + eager: [EXPLICIT_TRANSFORMATION, EXPLICIT_TRANSFORMATION2] + }) ]).then(wait(4000)).then(() => cloudinary.v2.api.delete_derived_by_transformation( [PUBLIC_ID_1, PUBLIC_ID_3], [EXPLICIT_TRANSFORMATION, EXPLICIT_TRANSFORMATION2] )).then( @@ -448,7 +448,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage({ public_id: PUBLIC_ID_3, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then( () => cloudinary.v2.api.resource(PUBLIC_ID_3) ).then(function (resource) { @@ -469,7 +469,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage({ public_id: "api_test_by_prefix", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then( () => cloudinary.v2.api.resource("api_test_by_prefix") ).then(function (resource) { @@ -514,20 +514,20 @@ describe("api", function () { it("should allow listing tags", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.api.tags({ - max_results: 500, + max_results: 500 }).then(result => expect(result.tags).not.to.be.empty()); }); it("should allow listing tag by prefix ", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.api.tags({ prefix: TEST_TAG.slice(0, -1), - max_results: 500, + max_results: 500 }).then(result => expect(result.tags).to.contain(TEST_TAG)); }); it("should allow listing tag by prefix if not found", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.api.tags({ - prefix: "api_test_no_such_tag", + prefix: "api_test_no_such_tag" }).then(result => expect(result.tags).to.be.empty()); }); }); @@ -552,7 +552,7 @@ describe("api", function () { [ cloudinary.v2.api.delete_transformation(transformationName), cloudinary.v2.api.delete_transformation(NAMED_TRANSFORMATION), - cloudinary.v2.api.delete_transformation(NAMED_TRANSFORMATION2), + cloudinary.v2.api.delete_transformation(NAMED_TRANSFORMATION2) ] ).finally(function () {}); }); @@ -581,14 +581,14 @@ describe("api", function () { it("should allow updating transformation allowed_for_strict", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.api.update_transformation(EXPLICIT_TRANSFORMATION_NAME, { - allowed_for_strict: true, + allowed_for_strict: true }).then( () => cloudinary.v2.api.transformation(EXPLICIT_TRANSFORMATION_NAME) ).then(function (transformation) { expect(transformation).not.to.eql(void 0); expect(transformation.allowed_for_strict).to.be.ok(); return cloudinary.v2.api.update_transformation(EXPLICIT_TRANSFORMATION_NAME, { - allowed_for_strict: false, + allowed_for_strict: false }); }).then(() => cloudinary.v2.api.transformation(EXPLICIT_TRANSFORMATION_NAME)).then(function (transformation) { expect(transformation).not.to.eql(void 0); @@ -600,7 +600,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.api.create_transformation(NAMED_TRANSFORMATION, { crop: "scale", - width: 102, + width: 102 }).then( () => cloudinary.v2.api.transformation(NAMED_TRANSFORMATION) ).then(function (transformation) { @@ -609,8 +609,8 @@ describe("api", function () { expect(transformation.info).to.eql([ { crop: "scale", - width: 102, - }, + width: 102 + } ]); expect(transformation.used).not.to.be.ok(); }); @@ -620,7 +620,7 @@ describe("api", function () { return cloudinary.v2.api.create_transformation(NAMED_TRANSFORMATION2, { crop: "scale", width: 102, - format: '', + format: '' }).then( () => cloudinary.v2.api.transformation(NAMED_TRANSFORMATION2) ).then(function (transformation) { @@ -630,8 +630,8 @@ describe("api", function () { { crop: "scale", width: 102, - extension: 'none', - }, + extension: 'none' + } ]); expect(transformation.used).not.to.be.ok(); }); @@ -639,10 +639,10 @@ describe("api", function () { it("should allow listing of named transformations", function () { return helper.mockPromise(function (xhr, write, request) { cloudinary.v2.api.transformations({ - named: true, + named: true }); return sinon.assert.calledWith(request, sinon.match({ - query: sinon.match('named=true'), + query: sinon.match('named=true') }, "named=true")); }); }); @@ -650,12 +650,12 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.api.create_transformation(transformationName, { crop: "scale", - width: 102, + width: 102 }).then(() => cloudinary.v2.api.update_transformation(transformationName, { unsafe_update: { crop: "scale", - width: 103, - }, + width: 103 + } })).then( () => cloudinary.v2.api.transformation(transformationName) ).then((transformation) => { @@ -663,8 +663,8 @@ describe("api", function () { expect(transformation.info).to.eql([ { crop: "scale", - width: 103, - }, + width: 103 + } ]); expect(transformation.used).not.to.be.ok(); }); @@ -695,7 +695,7 @@ describe("api", function () { return helper.mockPromise(function (xhr, write, request) { cloudinary.v2.api.upload_presets(); return sinon.assert.calledWith(request, sinon.match({ - pathname: sinon.match(/.*\/upload_presets$/), + pathname: sinon.match(/.*\/upload_presets$/) }, "upload_presets")); }); }); @@ -769,7 +769,7 @@ describe("api", function () { it("should allow deleting all derived resources", function () { return helper.mockPromise(function (xhr, write, request) { let options = { - keep_original: true, + keep_original: true }; cloudinary.v2.api.delete_all_resources(options); sinon.assert.calledWith(request, sinon.match(arg => new RegExp("/resources/image/upload$").test(arg.pathname), "/resources/image/upload")); @@ -794,10 +794,10 @@ describe("api", function () { it("should support changing moderation status with notification-url", function () { this.timeout(TIMEOUT.LONG); return uploadImage({ - moderation: "manual", + moderation: "manual" }).then(upload_result => cloudinary.v2.api.update(upload_result.public_id, { moderation_status: "approved", - notification_url: "http://example.com", + notification_url: "http://example.com" })).then(function () { if (writeSpy.called) { sinon.assert.calledWith(writeSpy, sinon.match(/notification_url=http%3A%2F%2Fexample.com/)); @@ -819,9 +819,9 @@ describe("api", function () { it("should support setting manual moderation status", function() { this.timeout(TIMEOUT.LONG); return uploadImage({ - moderation: "manual", + moderation: "manual" }).then(upload_result => cloudinary.v2.api.update(upload_result.public_id, { - moderation_status: "approved", + moderation_status: "approved" })).then(api_result => expect(api_result.moderation[0].status).to.eql("approved")) .catch((err) => { console.og(err); @@ -831,7 +831,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage() .then(upload_result => cloudinary.v2.api.update(upload_result.public_id, { - ocr: "illegal", + ocr: "illegal" })).then( () => expect().fail() ).catch(({ error }) => expect(error.message).to.contain("Illegal value")); @@ -840,7 +840,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage() .then(upload_result => cloudinary.v2.api.update(upload_result.public_id, { - raw_convert: "illegal", + raw_convert: "illegal" })).then( () => expect().fail() ).catch(({ error }) => expect(error.message).to.contain("Illegal value")); @@ -849,7 +849,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage().then(function (upload_result) { return cloudinary.v2.api.update(upload_result.public_id, { - categorization: "illegal", + categorization: "illegal" }); }).then(() => { expect().fail(); @@ -861,7 +861,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage() .then(upload_result => cloudinary.v2.api.update(upload_result.public_id, { - detection: "illegal", + detection: "illegal" })).then( () => expect().fail() ).catch(({ error }) => expect(error.message).to.contain("Illegal value")); @@ -870,7 +870,7 @@ describe("api", function () { this.timeout(TIMEOUT.MEDIUM); return uploadImage() .then(upload_result => cloudinary.v2.api.update(upload_result.public_id, { - background_removal: "illegal", + background_removal: "illegal" })).then( () => expect().fail() ).catch(({ error }) => expect(error.message).to.contain("Illegal value")); @@ -880,12 +880,12 @@ describe("api", function () { acl = { access_type: 'anonymous', start: new Date(Date.UTC(2019, 1, 22, 16, 20, 57)), - end: '2019-03-22 00:00 +0200', + end: '2019-03-22 00:00 +0200' }; acl_string = '{"access_type":"anonymous","start":"2019-02-22T16:20:57.000Z","end":"2019-03-22 00:00 +0200"}'; options = { public_id: TEST_TAG, - tags: [...UPLOAD_TAGS, 'access_control_test'], + tags: [...UPLOAD_TAGS, 'access_control_test'] }; it("should allow the user to define ACL in the update parameters2", function () { return helper.mockPromise((xhr, writeSpy, requestSpy) => { @@ -906,7 +906,7 @@ describe("api", function () { status2 = status; request.resetHistory(); cloudinary.v2.api.resources_by_moderation("manual", status2, { - moderations: true, + moderations: true }); sinon.assert.calledWith(request, sinon.match( arg => new RegExp(`/resources/image/moderations/manual/${status2}$`).test(arg != null ? arg.pathname : void 0), `/resources/image/moderations/manual/${status}` @@ -924,24 +924,24 @@ describe("api", function () { return Q.all([ uploadImage({ public_id: 'test_folder1/item', - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }), uploadImage({ public_id: 'test_folder2/item', - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }), uploadImage({ public_id: 'test_folder2/item', - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }), uploadImage({ public_id: 'test_folder1/test_subfolder1/item', - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }), uploadImage({ public_id: 'test_folder1/test_subfolder2/item', - tags: UPLOAD_TAGS, - }), + tags: UPLOAD_TAGS + }) ]).then(wait(TIMEOUT.SHORT)) .then(function (results) { return Q.all([cloudinary.v2.api.root_folders(), cloudinary.v2.api.sub_folders('test_folder1')]); @@ -977,7 +977,7 @@ describe("api", function () { cloudinary.v2.api.create_folder(folderPath); sinon.assert.calledWith(request, sinon.match({ pathname: sinon.match(expectedPath), - method: sinon.match("POST"), + method: sinon.match("POST") })); }); }); @@ -988,7 +988,7 @@ describe("api", function () { before(function () { return uploadImage({ folder: folderPath, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).delay(2 * 1000).then(function () { return cloudinary.v2.api.delete_resources_by_prefix(folderPath) .then(() => cloudinary.v2.api.sub_folders(folderPath).then(folder => { @@ -1015,7 +1015,7 @@ describe("api", function () { before(() => uploadImage({ public_id: publicId, backup: true, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(wait(2000)).then(() => cloudinary.v2.api.resource(publicId)).then((resource) => { expect(resource).not.to.be(null); expect(resource.bytes).to.eql(3381); @@ -1132,14 +1132,14 @@ describe("api", function () { return cloudinary.v2.api .create_upload_mapping(this.mapping, { template: "http://cloudinary.com", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then( () => cloudinary.v2.api.upload_mapping(this.mapping) ).then((result) => { this.deleteMapping = true; expect(result.template).to.eql("http://cloudinary.com"); return cloudinary.v2.api.update_upload_mapping(this.mapping, { - template: "http://res.cloudinary.com", + template: "http://res.cloudinary.com" }); }).then( result => cloudinary.v2.api.upload_mapping(this.mapping) @@ -1177,13 +1177,13 @@ describe("api", function () { after(function () { // cleanup any resource that were not published return cloudinary.v2.api.delete_resources(idsToDelete, { - type: "authenticated", + type: "authenticated" }); }); it("should publish by public id", function () { this.timeout(TIMEOUT.LONG); return cloudinary.v2.api.publish_by_ids([publishTestId], { - type: "authenticated", + type: "authenticated" }).then(function (result) { let published = result.published; expect(published).not.to.be(null); @@ -1215,7 +1215,7 @@ describe("api", function () { it("should return empty when explicit given type doesn't match resource", function () { this.timeout(TIMEOUT.LONG); return cloudinary.v2.api.publish_by_ids([publishTestId], { - type: "private", + type: "private" }).then(function (result) { let published = result.published; expect(published).not.to.be(null); @@ -1234,7 +1234,7 @@ describe("api", function () { access_mode_tag = TEST_TAG + "access_mode" + i++; const result = await uploadImage({ access_mode: "authenticated", - tags: UPLOAD_TAGS.concat([access_mode_tag]), + tags: UPLOAD_TAGS.concat([access_mode_tag]) }); await wait(5000)(); diff --git a/test/integration/api/provisioning/account_spec.js b/test/integration/api/provisioning/account_spec.js index 34f4d714..660b6db9 100644 --- a/test/integration/api/provisioning/account_spec.js +++ b/test/integration/api/provisioning/account_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require("expect.js"); @@ -76,7 +76,7 @@ runOnlyForInternalPRs('account API - Provisioning', function () { let NEW_NAME = 'This wont be created'; let options = { provisioning_api_key: 'abc', - provisioning_api_secret: 'abc', + provisioning_api_secret: 'abc' }; await cloudinary.provisioning.account.create_sub_account(CLOUD_ID, NEW_NAME, {}, null, null, options).catch((errRes) => { diff --git a/test/integration/api/search/search_spec.js b/test/integration/api/search/search_spec.js index 21a33611..e0edf77f 100644 --- a/test/integration/api/search/search_spec.js +++ b/test/integration/api/search/search_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require('expect.js'); @@ -15,17 +15,17 @@ const { TIMEOUT, TAGS, PUBLIC_IDS, - UNIQUE_JOB_SUFFIX_ID, + UNIQUE_JOB_SUFFIX_ID } = testConstants; const { PUBLIC_ID_1, PUBLIC_ID_2, - PUBLIC_ID_3, + PUBLIC_ID_3 } = PUBLIC_IDS; const { - UPLOAD_TAGS, + UPLOAD_TAGS } = TAGS; const SEARCH_TAG = 'npm_advanced_search_' + UNIQUE_JOB_SUFFIX_ID; @@ -46,13 +46,13 @@ describe("search_api", function () { 'max_results', 'next_cursor', 'aggregate', - 'with_field', + 'with_field' ].forEach(method => expect(instance).to.eql(instance[method]('emptyarg'))); }); it('should add expression to query', function () { var query = cloudinary.v2.search.expression('format:jpg').to_query(); expect(query).to.eql({ - expression: 'format:jpg', + expression: 'format:jpg' }); }); it('should add sort_by to query', function () { @@ -60,36 +60,36 @@ describe("search_api", function () { expect(query).to.eql({ sort_by: [ { - created_at: 'asc', + created_at: 'asc' }, { - updated_at: 'desc', - }, - ], + updated_at: 'desc' + } + ] }); }); it('should add max_results to query', function () { var query = cloudinary.v2.search.max_results('format:jpg').to_query(); expect(query).to.eql({ - max_results: 'format:jpg', + max_results: 'format:jpg' }); }); it('should add next_cursor to query', function () { var query = cloudinary.v2.search.next_cursor('format:jpg').to_query(); expect(query).to.eql({ - next_cursor: 'format:jpg', + next_cursor: 'format:jpg' }); }); it('should add aggregate arguments as array to query', function () { var query = cloudinary.v2.search.aggregate('format').aggregate('size_category').to_query(); expect(query).to.eql({ - aggregate: ['format', 'size_category'], + aggregate: ['format', 'size_category'] }); }); it('should add with_field to query', function () { var query = cloudinary.v2.search.with_field('context').with_field('tags').to_query(); expect(query).to.eql({ - with_field: ['context', 'tags'], + with_field: ['context', 'tags'] }); }); }); @@ -108,22 +108,22 @@ describe("search_api", function () { public_id: PUBLIC_ID_1, tags: [...UPLOAD_TAGS, SEARCH_TAG], - context: "stage=in_review", + context: "stage=in_review" }), cloudinary.v2.uploader.upload(helper.IMAGE_FILE, { public_id: PUBLIC_ID_2, tags: [...UPLOAD_TAGS, SEARCH_TAG], - context: "stage=new", + context: "stage=new" }), cloudinary.v2.uploader.upload(helper.IMAGE_FILE, { public_id: PUBLIC_ID_3, tags: [...UPLOAD_TAGS, SEARCH_TAG], - context: "stage=validated", - }), + context: "stage=validated" + }) ]).delay(3000); // wait for the server to update }); after(function () { diff --git a/test/integration/api/uploader/uploader_spec.js b/test/integration/api/uploader/uploader_spec.js index 79472bef..eee80ed4 100644 --- a/test/integration/api/uploader/uploader_spec.js +++ b/test/integration/api/uploader/uploader_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const https = require('https'); @@ -34,12 +34,12 @@ const UPLOADER_V2 = cloudinary.v2.uploader; const { TIMEOUT, - TAGS, + TAGS } = testConstants; const { TEST_TAG, - UPLOAD_TAGS, + UPLOAD_TAGS } = TAGS; require('jsdom-global')(); @@ -62,8 +62,8 @@ describe("uploader", function () { !cloudinary.config().keep_test_products ? cloudinary.v2.api.delete_resources_by_tag(TEST_TAG) : void 0, !cloudinary.config().keep_test_products ? cloudinary.v2.api.delete_resources_by_tag(TEST_TAG, { - resource_type: "video", - }) : void 0, + resource_type: "video" + }) : void 0 ]); }); beforeEach(function () { @@ -78,7 +78,7 @@ describe("uploader", function () { expect(result.height).to.eql(51); expected_signature = cloudinary.utils.api_sign_request({ public_id: result.public_id, - version: result.version, + version: result.version }, cloudinary.config().api_secret); expect(result.signature).to.eql(expected_signature); }); @@ -88,21 +88,21 @@ describe("uploader", function () { const metadata_fields = METADATA_SAMPLE_DATA; uploadImage({ metadata: metadata_fields }); sinon.assert.calledWith(request, sinon.match({ - method: sinon.match("POST"), + method: sinon.match("POST") })); sinon.assert.calledWith(write, sinon.match(helper.uploadParamMatcher("metadata", METADATA_SAMPLE_DATA_ENCODED))); }); }); it("should successfully upload url", function () { return cloudinary.v2.uploader.upload("http://cloudinary.com/images/old_logo.png", { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { var expected_signature; expect(result.width).to.eql(241); expect(result.height).to.eql(51); expected_signature = cloudinary.utils.api_sign_request({ public_id: result.public_id, - version: result.version, + version: result.version }, cloudinary.config().api_secret); expect(result.signature).to.eql(expected_signature); }); @@ -113,7 +113,7 @@ describe("uploader", function () { return cloudinary.v2.uploader.upload(data, { resource_type: 'auto', // this defaults to 'image' if not specified - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }); }); @@ -121,19 +121,19 @@ describe("uploader", function () { const mocked = helper.mockTest(); it("should send s3:// URLs to server", function () { cloudinary.v2.uploader.upload("s3://test/1.jpg", { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }); sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "s3://test/1.jpg"))); }); it("should send gs:// URLs to server", function () { cloudinary.v2.uploader.upload("gs://test/1.jpg", { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }); sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "gs://test/1.jpg"))); }); it("should send ftp:// URLs to server", function () { cloudinary.v2.uploader.upload("ftp://example.com/1.jpg", { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }); sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher('file', "ftp://example.com/1.jpg"))); }); @@ -162,7 +162,7 @@ describe("uploader", function () { it("should allow to rename to an existing ID, if overwrite is true", function () { return Promise.all([uploadImage(), uploadImage()]).then(function (results) { return cloudinary.v2.uploader.rename(results[0].public_id, results[1].public_id, { - overwrite: true, + overwrite: true }); }).then(function ({ public_id }) { return cloudinary.v2.api.resource(public_id); @@ -184,7 +184,7 @@ describe("uploader", function () { }); it("should should pass the invalidate value in rename to the server", function () { cloudinary.v2.uploader.rename("first_id", "second_id", { - invalidate: true, + invalidate: true }); expect(spy.calledWith(sinon.match(function (arg) { return arg.toString().match(/name="invalidate"/); @@ -215,10 +215,10 @@ describe("uploader", function () { eager: [ { crop: "scale", - width: "2.0", - }, + width: "2.0" + } ], - async: true, + async: true }).then(function (result) { expect(result.status).to.eql('pending'); expect(result.resource_type).to.eql('image'); @@ -232,16 +232,16 @@ describe("uploader", function () { eager: [ { crop: "scale", - width: "2.0", - }, - ], + width: "2.0" + } + ] }).then(function (result) { var url = cloudinary.utils.url("sample", { type: "upload", crop: "scale", width: "2.0", format: "jpg", - version: result.version, + version: result.version }); expect(result.eager[0].url).to.eql(url); }); @@ -252,32 +252,32 @@ describe("uploader", function () { eager: [ { crop: "scale", - width: "2.0", - }, + width: "2.0" + } ], - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }); }); describe("custom headers", function () { it("should support custom headers in object format e.g. {Link: \"1\"}", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { headers: { - Link: "1", + Link: "1" }, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }); }); it("should support custom headers as array of strings e.g. [\"Link: 1\"]", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { headers: ["Link: 1"], - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }); }); }); describe("text images", function () { it("should successfully generate text image", function () { return cloudinary.v2.uploader.text("hello world", { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result.width).to.within(50, 70); expect(result.height).to.within(5, 15); @@ -289,7 +289,7 @@ describe("uploader", function () { { font_family: "Arial", font_size: 12, - font_weight: "black", + font_weight: "black" }); sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher("font_family", "Arial"))); sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher("font_size", "12"))); @@ -299,20 +299,20 @@ describe("uploader", function () { it("should successfully upload stream", function (done) { var file_reader, stream; stream = cloudinary.v2.uploader.upload_stream({ - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { var expected_signature; expect(result.width).to.eql(241); expect(result.height).to.eql(51); expected_signature = cloudinary.utils.api_sign_request({ public_id: result.public_id, - version: result.version, + version: result.version }, cloudinary.config().api_secret); expect(result.signature).to.eql(expected_signature); done(); }); file_reader = fs.createReadStream(IMAGE_FILE, { - encoding: 'binary', + encoding: 'binary' }); file_reader.on('data', function (chunk) { stream.write(chunk, 'binary'); @@ -365,7 +365,7 @@ describe("uploader", function () { }); it("should replace existing tag", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { - tags: ["tag1", "tag2", TEST_TAG], + tags: ["tag1", "tag2", TEST_TAG] }).then(function (result) { var public_id = result.public_id; return cloudinary.v2.uploader.replace_tag("tag3Å", public_id).then(function () { @@ -391,7 +391,7 @@ describe("uploader", function () { .add_context('alt=testAlt|custom=testCustom', [this.first_id, this.second_id]) .then(() => cloudinary.v2.uploader.add_context({ alt2: "testAlt2", - custom2: "testCustom2", + custom2: "testCustom2" }, [this.first_id, this.second_id])) .then(() => cloudinary.v2.api.resource(this.second_id)) .then(({ context }) => { @@ -414,13 +414,13 @@ describe("uploader", function () { key1: 'value1', key2: 'valu\e2', key3: 'val=u|e3', - key4: 'val\=ue', + key4: 'val\=ue' }; return cloudinary.v2.uploader.upload(IMAGE_FILE, { - context: context, + context: context }).then(function (result) { return cloudinary.v2.api.resource(result.public_id, { - context: true, + context: true }); }).then(function (result) { expect(result.context.custom).to.eql(context); @@ -431,7 +431,7 @@ describe("uploader", function () { // testing a 1ms timeout, nobody is that fast. return cloudinary.v2.uploader.upload("http://cloudinary.com/images/old_logo.png", { timeout: 1, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { expect().fail(); }).catch(function ({ error }) { @@ -443,7 +443,7 @@ describe("uploader", function () { this.timeout(TIMEOUT.MEDIUM); return cloudinary.v2.uploader.upload(IMAGE_FILE, { use_filename: true, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function ({ public_id }) { expect(public_id).to.match(/logo_[a-zA-Z0-9]{6}/); }); @@ -452,7 +452,7 @@ describe("uploader", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { use_filename: true, unique_filename: false, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result.public_id).to.eql("logo"); }); @@ -461,7 +461,7 @@ describe("uploader", function () { it("should allow whitelisted formats", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { allowed_formats: ["png"], - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result.format).to.eql("png"); }); @@ -469,7 +469,7 @@ describe("uploader", function () { it("should prevent non whitelisted formats from being uploaded", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { allowed_formats: ["jpg"], - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { expect().fail(); }).catch(function (error) { @@ -480,7 +480,7 @@ describe("uploader", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { allowed_formats: ["jpg"], format: "jpg", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result.format).to.eql("jpg"); }); @@ -499,34 +499,34 @@ describe("uploader", function () { 121, 31, 110, - 51, // coordinates are limited to the image dimensions - ], + 51 // coordinates are limited to the image dimensions + ] ]; different_coordinates = [[122, 32, 111, 152]]; custom_coordinates = [1, 2, 3, 4]; return cloudinary.v2.uploader.upload(IMAGE_FILE, { face_coordinates: coordinates, faces: true, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result.faces).to.eql(out_coordinates); return cloudinary.v2.uploader.explicit(result.public_id, { faces: true, face_coordinates: different_coordinates, custom_coordinates: custom_coordinates, - type: "upload", + type: "upload" }); }).then(function (result) { expect(result.faces).not.to.be(void 0); return cloudinary.v2.api.resource(result.public_id, { faces: true, - coordinates: true, + coordinates: true }); }).then(function (info) { expect(info.faces).to.eql(different_coordinates); expect(info.coordinates).to.eql({ faces: different_coordinates, - custom: [custom_coordinates], + custom: [custom_coordinates] }); }); }); @@ -535,12 +535,12 @@ describe("uploader", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { context: { caption: "some caption", - alt: "alternative", + alt: "alternative" }, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function ({ public_id }) { return cloudinary.v2.api.resource(public_id, { - context: true, + context: true }); }).then(function ({ context }) { expect(context.custom.caption).to.eql("some caption"); @@ -551,7 +551,7 @@ describe("uploader", function () { this.timeout(TIMEOUT.LONG); return cloudinary.v2.uploader.upload(IMAGE_FILE, { moderation: "manual", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result.moderation[0].status).to.eql("pending"); expect(result.moderation[0].kind).to.eql("manual"); @@ -560,7 +560,7 @@ describe("uploader", function () { it("should support requesting ocr analysis", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { ocr: "adv_ocr", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result.info.ocr).to.have.key("adv_ocr"); }); @@ -569,7 +569,7 @@ describe("uploader", function () { return cloudinary.v2.uploader.upload(RAW_FILE, { raw_convert: "illegal", resource_type: "raw", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { expect().fail(); }).catch(function (error) { @@ -580,7 +580,7 @@ describe("uploader", function () { it("should support requesting categorization", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { categorization: "illegal", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { expect().fail(); }).catch(function (error) { @@ -590,7 +590,7 @@ describe("uploader", function () { it("should support requesting detection", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { detection: "illegal", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { expect().fail(); }).catch(function (error) { @@ -601,7 +601,7 @@ describe("uploader", function () { it("should support requesting background_removal", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { background_removal: "illegal", - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { expect().fail(); }).catch(function (error) { @@ -612,7 +612,7 @@ describe("uploader", function () { it("should support requesting analysis", function () { return cloudinary.v2.uploader.upload(IMAGE_FILE, { quality_analysis: true, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result).to.have.key("quality_analysis"); }); @@ -624,7 +624,7 @@ describe("uploader", function () { cloudinary.v2.uploader.upload_large(LARGE_RAW_FILE, { chunk_size: 7000000, timeout: TIMEOUT.LONG, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { if (error != null) { done(new Error(error.message)); @@ -639,7 +639,7 @@ describe("uploader", function () { fs.stat(LARGE_RAW_FILE, function (err, stat) { cloudinary.v2.uploader.upload_large(LARGE_RAW_FILE, { chunk_size: 40000, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { expect(error.message).to.eql("All parts except EOF-chunk must be larger than 5mb"); done(); @@ -649,7 +649,7 @@ describe("uploader", function () { it("should use file name", function (done) { fs.stat(LARGE_RAW_FILE, function (err, stat) { return cloudinary.v2.uploader.upload_large(LARGE_RAW_FILE, { - use_filename: true, + use_filename: true }, function (error, result) { if (error != null) { done(new Error(error.message)); @@ -662,7 +662,7 @@ describe("uploader", function () { it("should support uploading a small raw file", function (done) { fs.stat(RAW_FILE, function (err, stat) { cloudinary.v2.uploader.upload_large(RAW_FILE, { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { if (error != null) { done(new Error(error.message)); @@ -676,7 +676,7 @@ describe("uploader", function () { it("should add original filename on upload large", function (done) { fs.stat(RAW_FILE, function (err, stat) { cloudinary.v2.uploader.upload_large(RAW_FILE, { - filename: 'my_file_name', + filename: 'my_file_name' }, function (error, result) { if (error != null) { done(new Error(error.message)); @@ -689,7 +689,7 @@ describe("uploader", function () { it("should support uploading a small image file", function (done) { fs.stat(IMAGE_FILE, function (err, stat) { return cloudinary.v2.uploader.upload_chunked(IMAGE_FILE, { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { if (error != null) { done(new Error(error.message)); @@ -710,7 +710,7 @@ describe("uploader", function () { chunk_size: 6000000, resource_type: 'video', timeout: TIMEOUT.LONG * 10, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { var timestamps; expect(result.bytes).to.eql(stat.size); @@ -734,7 +734,7 @@ describe("uploader", function () { chunk_size: 6000000, resource_type: 'video', timeout: TIMEOUT.LONG * 10, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { var timestamps = writeSpy.args.map(function (a) { return a[0].toString(); @@ -752,7 +752,7 @@ describe("uploader", function () { it("should support uploading based on a url", function (done) { this.timeout(TIMEOUT.MEDIUM); cloudinary.v2.uploader.upload_large("http://cloudinary.com/images/old_logo.png", { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { if (error != null) { done(new Error(error.message)); @@ -768,14 +768,14 @@ describe("uploader", function () { let preset = await cloudinary.v2.api.create_upload_preset({ folder: "upload_folder", unsigned: true, - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).catch((err) => { console.log(err); throw new Error('create_upload_preset failed'); }); let uploadResponse = await cloudinary.v2.uploader.unsigned_upload(IMAGE_FILE, preset.name, { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).catch((err) => { console.log(err); throw new Error('unsigned_upload failed'); @@ -791,7 +791,7 @@ describe("uploader", function () { it("should reject promise if error code is returned from the server", function () { return cloudinary.v2.uploader.upload(EMPTY_IMAGE, { - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function () { expect().fail("server should return an error when uploading an empty file"); }).catch(function (error) { @@ -802,14 +802,14 @@ describe("uploader", function () { var file_reader, upload; this.timeout(TIMEOUT.LONG); upload = cloudinary.v2.uploader.upload_stream({ - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { var expected_signature; expect(result.width).to.eql(241); expect(result.height).to.eql(51); expected_signature = cloudinary.utils.api_sign_request({ public_id: result.public_id, - version: result.version, + version: result.version }, cloudinary.config().api_secret); expect(result.signature).to.eql(expected_signature); done(); @@ -820,21 +820,21 @@ describe("uploader", function () { it("should fail with http.Agent (non secure)", function () { this.timeout(TIMEOUT.LONG); expect(cloudinary.v2.uploader.upload_stream).withArgs({ - agent: new http.Agent(), + agent: new http.Agent() }, function (error, result) {}).to.throwError(); }); it("should successfully override https agent", function () { var file_reader, upload; upload = cloudinary.v2.uploader.upload_stream({ agent: new https.Agent(), - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }, function (error, result) { var expected_signature; expect(result.width).to.eql(241); expect(result.height).to.eql(51); expected_signature = cloudinary.utils.api_sign_request({ public_id: result.public_id, - version: result.version, + version: result.version }, cloudinary.config().api_secret); expect(result.signature).to.eql(expected_signature); }); @@ -851,28 +851,28 @@ describe("uploader", function () { responsive_breakpoints: [ { transformation: { - effect: "sepia", + effect: "sepia" }, format: "jpg", bytes_step: 20000, create_derived: true, min_width: 200, max_width: 1000, - max_images: 20, + max_images: 20 }, { transformation: { - angle: 10, + angle: 10 }, format: "gif", create_derived: true, bytes_step: 20000, min_width: 200, max_width: 1000, - max_images: 20, - }, + max_images: 20 + } ], - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }).then(function (result) { expect(result).to.have.key('responsive_breakpoints'); expect(result.responsive_breakpoints).to.have.length(2); @@ -885,7 +885,7 @@ describe("uploader", function () { format = path.extname(bp.breakpoints[0].url).slice(1); cached = cloudinary.Cache.get(result.public_id, { raw_transformation: bp.transformation, - format, + format }); expect(cached).to.be.ok(); expect(cached.length).to.be(bp.breakpoints.length); @@ -903,8 +903,8 @@ describe("uploader", function () { cloudinary.v2.uploader.upload(IMAGE_FILE, { async: true, transformation: { - effect: "sepia", - }, + effect: "sepia" + } }); sinon.assert.calledWith(mocked.write, sinon.match(helper.uploadParamMatcher("async", 1))); }); @@ -928,12 +928,12 @@ describe("uploader", function () { eager: [ { crop: "scale", - width: "2.0", - }, + width: "2.0" + } ], invalidate: true, quality_analysis: true, - tags: [TEST_TAG], + tags: [TEST_TAG] }); sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('invalidate', 1))); sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('quality_analysis', 1))); @@ -947,7 +947,7 @@ describe("uploader", function () { it("should support raw_convert", function () { cloudinary.v2.uploader.explicit("cloudinary", { raw_convert: "google_speech", - tags: [TEST_TAG], + tags: [TEST_TAG] }); sinon.assert.calledWith(spy, sinon.match(helper.uploadParamMatcher('raw_convert', 'google_speech'))); }); @@ -956,7 +956,7 @@ describe("uploader", function () { var fakeDiv, input_element, tag; this.timeout(TIMEOUT.LONG); tag = cloudinary.v2.uploader.image_upload_tag("image_id", { - chunk_size: "1234", + chunk_size: "1234" }); expect(tag).to.match(/^ testValue(value)); it("should be supported by explicit api", function () { cloudinary.v2.uploader.explicit("cloudinary", { - "quality_override": "auto:best", + "quality_override": "auto:best" }); sinon.assert.calledWithMatch(mocked.write, helper.uploadParamMatcher("quality_override", "auto:best")); }); @@ -998,7 +998,7 @@ describe("uploader", function () { return helper.mockPromise(function (xhr, write, request) { cloudinary.v2.uploader.update_metadata(metadata_fields, public_ids); sinon.assert.calledWith(request, sinon.match({ - method: sinon.match("POST"), + method: sinon.match("POST") })); sinon.assert.calledWith(write, sinon.match(helper.uploadParamMatcher("metadata", "metadata_color=red|metadata_shape="))); sinon.assert.calledWith(write, sinon.match(helper.uploadParamMatcher("public_ids[]", public_ids[0]))); @@ -1016,7 +1016,7 @@ describe("uploader", function () { requestSpy = sinon.spy(http, 'request'); options = { public_id: TEST_TAG, - tags: [...UPLOAD_TAGS, 'access_control_test'], + tags: [...UPLOAD_TAGS, 'access_control_test'] }; }); afterEach(function () { @@ -1026,7 +1026,7 @@ describe("uploader", function () { acl = { access_type: 'anonymous', start: new Date(Date.UTC(2019, 1, 22, 16, 20, 57)), - end: '2019-03-22 00:00 +0200', + end: '2019-03-22 00:00 +0200' }; acl_string = '{"access_type":"anonymous","start":"2019-02-22T16:20:57.000Z","end":"2019-03-22 00:00 +0200"}'; it("should allow the user to define ACL in the upload parameters", function () { @@ -1050,7 +1050,7 @@ describe("uploader", function () { return cloudinary.v2.api.add_metadata_field({ external_id: METADATA_FIELD_UNIQUE_EXTERNAL_ID, label: METADATA_FIELD_UNIQUE_EXTERNAL_ID, - type: "string", + type: "string" }).finally(function () {}); }); after(function () { @@ -1060,18 +1060,18 @@ describe("uploader", function () { it("should be set when calling upload with metadata", function () { return uploadImage({ tags: UPLOAD_TAGS, - metadata: metadata_fields, + metadata: metadata_fields }).then((result) => { expect(result.metadata[METADATA_FIELD_UNIQUE_EXTERNAL_ID]).to.eql(METADATA_FIELD_VALUE); }); }); it("should be set when calling explicit with metadata", function () { return uploadImage({ - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }) .then(result => cloudinary.v2.uploader.explicit(result.public_id, { type: "upload", - metadata: metadata_fields, + metadata: metadata_fields })) .then((result) => { expect(result.metadata[METADATA_FIELD_UNIQUE_EXTERNAL_ID]).to.eql(METADATA_FIELD_VALUE); @@ -1080,7 +1080,7 @@ describe("uploader", function () { it("should be updatable with uploader.update_metadata on an existing resource", function () { let publicId; return uploadImage({ - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }) .then((result) => { publicId = result.public_id; @@ -1099,11 +1099,11 @@ describe("uploader", function () { return Q.allSettled( [ uploadImage({ - tags: UPLOAD_TAGS, + tags: UPLOAD_TAGS }), uploadImage({ - tags: UPLOAD_TAGS, - }), + tags: UPLOAD_TAGS + }) ] ).then(function ([result_1, result_2]) { resource_1 = result_1.value; @@ -1127,7 +1127,7 @@ describe("uploader", function () { configBck2 = cloudinary.config(); cloudinary.config({ api_key: "1234", - api_secret: "", + api_secret: "" }); }); afterEach(function () { @@ -1139,7 +1139,7 @@ describe("uploader", function () { public_id: 'folder/file', version: '1234', timestamp: 1569707219, - signature: 'b77fc0b0dffbf7e74bdad36b615225fb6daff81e', + signature: 'b77fc0b0dffbf7e74bdad36b615225fb6daff81e' }); sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('signature', "b77fc0b0dffbf7e74bdad36b615225fb6daff81e"))); sinon.assert.calledWith(writeSpy, sinon.match(helper.uploadParamMatcher('timestamp', '1569707219'))); @@ -1151,7 +1151,7 @@ describe("uploader", function () { // Upload an image and request a cinemagraph analysis value in the response const result = await UPLOADER_V2.upload(IMAGE_FILE, { "cinemagraph_analysis": true, - "tags": [TEST_TAG], + "tags": [TEST_TAG] }); // Ensure result includes a cinemagraph_analysis with a cinemagraph_score @@ -1163,14 +1163,14 @@ describe("uploader", function () { it("should support requesting a cinemagraph_analysis when calling explicit", async function () { // Upload an image const uploadResult = await UPLOADER_V2.upload(IMAGE_FILE, { - "tags": [TEST_TAG], + "tags": [TEST_TAG] }); // Call explicit on the uploaded image and request a cinemagraph analysis value in the response const explicitResult = await UPLOADER_V2.explicit(uploadResult.public_id, { "cinemagraph_analysis": true, "tags": [TEST_TAG], - type: "upload", + type: "upload" }); // Ensure result includes a cinemagraph_analysis with a cinemagraph_score diff --git a/test/source_tag_spec.js b/test/source_tag_spec.js index cd209d3f..08ca6838 100644 --- a/test/source_tag_spec.js +++ b/test/source_tag_spec.js @@ -19,17 +19,17 @@ describe('source helper', function () { max_width = 399; breakpoint_list = [min_width, 200, 300, max_width]; common_srcset = { - "breakpoints": breakpoint_list, + "breakpoints": breakpoint_list }; fill_transformation = { "width": max_width, "height": max_width, - "crop": "fill", + "crop": "fill" }; cloudinary.config(true); // Reset cloudinary.config(createTestConfig({ cloud_name: "test123", - api_secret: "1234", + api_secret: "1234" })); }); it("should generate a source tag", function () { @@ -39,7 +39,7 @@ describe('source helper', function () { var expectedMedia, expectedTag, media, tag; media = { min_width, max_width }; tag = cloudinary.source(FULL_PUBLIC_ID, { - media: media, + media: media }); expectedMedia = `(min-width: ${min_width}px) and (max-width: ${max_width}px)`; expectedTag = ``; @@ -47,7 +47,7 @@ describe('source helper', function () { }); it("should generate source tag with responsive srcset", function () { var tag = cloudinary.source(FULL_PUBLIC_ID, { - srcset: common_srcset, + srcset: common_srcset }); expect(tag).to.eql(""); }); @@ -60,8 +60,8 @@ describe('source helper', function () { "transformation": { "effect": "sepia", "angle": 17, - "width": min_width, - }, + "width": min_width + } }, { "min_width": min_width, @@ -69,18 +69,18 @@ describe('source helper', function () { "transformation": { "effect": "colorize", "angle": 18, - "width": max_width, - }, + "width": max_width + } }, { "min_width": max_width, "transformation": { "effect": "blur", "angle": 19, - "width": max_width, - }, - }, - ], + "width": max_width + } + } + ] }, fill_transformation)); exp_tag = "" + "" + "" + "" + "" + ""; expect(tag).to.eql(exp_tag); diff --git a/test/spechelper.js b/test/spechelper.js index 5157d046..d42afaee 100644 --- a/test/spechelper.js +++ b/test/spechelper.js @@ -35,21 +35,21 @@ exports.SAMPLE_VIDEO_SOURCES = [ { type: 'mp4', codecs: 'hev1', - transformations: { video_codec: 'h265' }, + transformations: { video_codec: 'h265' } }, { type: 'webm', codecs: 'vp9', - transformations: { video_codec: 'vp9' }, + transformations: { video_codec: 'vp9' } }, { type: 'mp4', - transformations: { video_codec: 'auto' }, + transformations: { video_codec: 'auto' } }, { type: 'webm', - transformations: { video_codec: 'auto' }, - }, + transformations: { video_codec: 'auto' } + } ]; exports.test_cloudinary_url = function(public_id, options, expected_url, expected_options) { diff --git a/test/streaming_profiles_spec.js b/test/streaming_profiles_spec.js index 2edc5813..3a9fa346 100644 --- a/test/streaming_profiles_spec.js +++ b/test/streaming_profiles_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require("expect.js"); @@ -32,7 +32,7 @@ describe('Cloudinary::Api', function () { return Q.allSettled([ cloudinary.v2.api.delete_streaming_profile(test_id_1), cloudinary.v2.api.delete_streaming_profile(test_id_1 + 'a'), - cloudinary.v2.api.delete_streaming_profile(test_id_3), + cloudinary.v2.api.delete_streaming_profile(test_id_3) ]); }); describe('create_streaming_profile', function () { @@ -44,10 +44,10 @@ describe('Cloudinary::Api', function () { crop: 'scale', width: '1200', height: '1200', - bit_rate: '5m', - }, - }, - ], + bit_rate: '5m' + } + } + ] }).then(function (result) { expect(result).not.to.be(void 0); }); @@ -61,11 +61,11 @@ describe('Cloudinary::Api', function () { crop: 'scale', width: '1200', height: '1200', - bit_rate: '5m', - }, - ], - }, - ], + bit_rate: '5m' + } + ] + } + ] }).then(function (result) { expect(result).not.to.be(void 0); }); @@ -89,10 +89,10 @@ describe('Cloudinary::Api', function () { crop: 'scale', width: '1200', height: '1200', - bit_rate: '5m', - }, - }, - ], + bit_rate: '5m' + } + } + ] }).then(function (result) { expect(result).not.to.be(void 0); return api.delete_streaming_profile(test_id_2); @@ -125,10 +125,10 @@ describe('Cloudinary::Api', function () { crop: 'scale', width: '1200', height: '1200', - bit_rate: '5m', - }, - }, - ], + bit_rate: '5m' + } + } + ] }).then(function (result) { expect(result).to.be.ok(); return api.update_streaming_profile(test_id_3, { @@ -138,10 +138,10 @@ describe('Cloudinary::Api', function () { crop: 'scale', width: '1000', height: '1000', - bit_rate: '4m', - }, - }, - ], + bit_rate: '4m' + } + } + ] }); }).then(function (result) { expect(result).to.be.ok(); @@ -156,9 +156,9 @@ describe('Cloudinary::Api', function () { crop: 'scale', width: 1000, height: 1000, - bit_rate: '4m', - }, - ], + bit_rate: '4m' + } + ] }); }); }); diff --git a/test/structured_metadata_spec.js b/test/structured_metadata_spec.js index baac7c12..db709f1d 100644 --- a/test/structured_metadata_spec.js +++ b/test/structured_metadata_spec.js @@ -27,57 +27,57 @@ const DATASOURCE_ENTRY_EXTERNAL_ID = 'metadata_datasource_entry_external_id' + T const datasource_single = [ { value: 'v1', - external_id: DATASOURCE_ENTRY_EXTERNAL_ID, - }, + external_id: DATASOURCE_ENTRY_EXTERNAL_ID + } ]; const datasource_multiple = [ { value: 'v2', - external_id: DATASOURCE_ENTRY_EXTERNAL_ID, + external_id: DATASOURCE_ENTRY_EXTERNAL_ID }, { - value: 'v3', + value: 'v3' }, { - value: 'v4', - }, + value: 'v4' + } ]; const metadata_fields_external_ids = [ EXTERNAL_ID_GENERAL, EXTERNAL_ID_DATE, EXTERNAL_ID_ENUM_2, EXTERNAL_ID_SET, EXTERNAL_ID_INT_VALIDATION, - EXTERNAL_ID_INT_VALIDATION_2, EXTERNAL_ID_DATE_VALIDATION, EXTERNAL_ID_DATE_VALIDATION_2, + EXTERNAL_ID_INT_VALIDATION_2, EXTERNAL_ID_DATE_VALIDATION, EXTERNAL_ID_DATE_VALIDATION_2 ]; const metadata_fields_to_create = [ { external_id: EXTERNAL_ID_GENERAL, - type: 'string', + type: 'string' }, { external_id: EXTERNAL_ID_ENUM_2, type: 'enum', datasource: { - values: datasource_multiple, - }, + values: datasource_multiple + } }, { external_id: EXTERNAL_ID_DELETE_2, - type: 'integer', + type: 'integer' }, { external_id: EXTERNAL_ID_SET_2, type: 'set', datasource: { - values: datasource_multiple, - }, + values: datasource_multiple + } }, { external_id: EXTERNAL_ID_SET_3, type: 'set', datasource: { - values: datasource_multiple, - }, - }, + values: datasource_multiple + } + } ]; const api = cloudinary.v2.api; @@ -113,7 +113,7 @@ describe("structured metadata api", function () { api.list_metadata_fields(); sinon.assert.calledWith(request, sinon.match({ pathname: sinon.match(new RegExp(expectedPath)), - method: sinon.match("GET"), + method: sinon.match("GET") })); }); }); @@ -135,12 +135,12 @@ describe("structured metadata api", function () { const metadata = { external_id: EXTERNAL_ID_STRING, label: EXTERNAL_ID_STRING, - type: 'string', + type: 'string' }; api.add_metadata_field(metadata); sinon.assert.calledWith(request, sinon.match({ pathname: sinon.match(new RegExp(expectedPath)), - method: sinon.match("POST"), + method: sinon.match("POST") })); sinon.assert.calledWith(write, sinon.match(helper.apiJsonParamMatcher('external_id', EXTERNAL_ID_STRING))); sinon.assert.calledWith(write, sinon.match(helper.apiJsonParamMatcher('type', 'string'))); @@ -152,12 +152,12 @@ describe("structured metadata api", function () { const metadata = { external_id: EXTERNAL_ID_INT, label: EXTERNAL_ID_INT, - type: 'integer', + type: 'integer' }; api.add_metadata_field(metadata); sinon.assert.calledWith(request, sinon.match({ pathname: sinon.match(new RegExp(expectedPath)), - method: sinon.match("POST"), + method: sinon.match("POST") })); sinon.assert.calledWith(write, sinon.match(helper.apiJsonParamMatcher('external_id', EXTERNAL_ID_INT))); sinon.assert.calledWith(write, sinon.match(helper.apiJsonParamMatcher('type', 'integer'))); @@ -168,7 +168,7 @@ describe("structured metadata api", function () { const metadata = { external_id: EXTERNAL_ID_DATE, label: EXTERNAL_ID_DATE, - type: 'date', + type: 'date' }; return api.add_metadata_field(metadata).then((result) => { expect(result).to.beAMetadataField(); @@ -181,16 +181,16 @@ describe("structured metadata api", function () { return helper.mockPromise(function (xhr, write, request) { const metadata = { datasource: { - values: datasource_single, + values: datasource_single }, external_id: EXTERNAL_ID_ENUM, label: EXTERNAL_ID_ENUM, - type: 'enum', + type: 'enum' }; api.add_metadata_field(metadata); sinon.assert.calledWith(request, sinon.match({ pathname: sinon.match(new RegExp(expectedPath)), - method: sinon.match("POST"), + method: sinon.match("POST") })); sinon.assert.calledWith(write, sinon.match(helper.apiJsonParamMatcher('external_id', EXTERNAL_ID_ENUM))); sinon.assert.calledWith(write, sinon.match(helper.apiJsonParamMatcher('type', 'enum'))); @@ -201,11 +201,11 @@ describe("structured metadata api", function () { it("should create set metadata field", function () { const metadata = { datasource: { - values: datasource_multiple, + values: datasource_multiple }, external_id: EXTERNAL_ID_SET, label: EXTERNAL_ID_SET, - type: 'set', + type: 'set' }; return api.add_metadata_field(metadata).then((result) => { expect(result).to.beAMetadataField(); @@ -215,7 +215,7 @@ describe("structured metadata api", function () { external_id: EXTERNAL_ID_SET, label: EXTERNAL_ID_SET, type: 'set', - mandatory: false, + mandatory: false }]).to.beAMetadataField(); }); }); @@ -230,7 +230,7 @@ describe("structured metadata api", function () { label: newLabel, type: 'integer', mandatory: true, - default_value: newDefaultValue, + default_value: newDefaultValue }; return api.update_metadata_field(EXTERNAL_ID_GENERAL, updatedMetadata) .then((result) => { @@ -243,7 +243,7 @@ describe("structured metadata api", function () { label: newLabel, type: 'string', mandatory: true, - default_value: newDefaultValue, + default_value: newDefaultValue }]).to.beAMetadataField(); }); }); @@ -267,7 +267,7 @@ describe("structured metadata api", function () { api.delete_metadata_field(EXTERNAL_ID_DELETE); sinon.assert.calledWith(request, sinon.match({ pathname: sinon.match(new RegExp(expectedPath)), - method: sinon.match("DELETE"), + method: sinon.match("DELETE") })); }); }); @@ -275,7 +275,7 @@ describe("structured metadata api", function () { const metadata = { external_id: EXTERNAL_ID_DELETE_2, label: EXTERNAL_ID_DELETE_2, - type: 'integer', + type: 'integer' }; return api.delete_metadata_field(EXTERNAL_ID_DELETE_2) .then((result) => { @@ -315,25 +315,25 @@ describe("structured metadata api", function () { { type: "greater_than", equals: false, - value: pastDate, + value: pastDate }, { type: "less_than", equals: false, - value: todayDate, - }, - ], + value: todayDate + } + ] }; const validMetadata = { external_id: EXTERNAL_ID_DATE_VALIDATION, label: EXTERNAL_ID_DATE_VALIDATION, type: 'date', default_value: yesterdayDate, - validation: lastThreeDaysValidation, + validation: lastThreeDaysValidation }; const invalidMetadata = { ...validMetadata, external_id: EXTERNAL_ID_DATE_VALIDATION_2, - default_value: futureDate, + default_value: futureDate }; it("should create date field when default value validation passes", function () { return api.add_metadata_field(validMetadata) @@ -361,7 +361,7 @@ describe("structured metadata api", function () { const validation = { type: 'less_than', equals: true, - value: 5, + value: 5 }; it("should create integer metadata with valid default value", function () { const metadata = { @@ -369,7 +369,7 @@ describe("structured metadata api", function () { label: EXTERNAL_ID_INT_VALIDATION, type: 'integer', default_value: 5, - validation, + validation }; return api.add_metadata_field(metadata) .then((result) => { @@ -387,7 +387,7 @@ describe("structured metadata api", function () { label: EXTERNAL_ID_INT_VALIDATION_2, type: 'integer', default_value: 6, - validation, + validation }; return api.add_metadata_field(metadata) .then((result) => { diff --git a/test/testUtils/assertions/beADatasource.js b/test/testUtils/assertions/beADatasource.js index cf2951ea..f24dc753 100644 --- a/test/testUtils/assertions/beADatasource.js +++ b/test/testUtils/assertions/beADatasource.js @@ -11,7 +11,7 @@ const ERRORS = { EXTERNAL_ID_MUST_BE_STRING: `expected datasource field to contain item with mandatory field: 'value' type string`, EXTERNAL_ID_MUST_NOT_BE_STRING: `expected datasource not to contain item with mandatory field 'external_id' type string`, STATE_MUST_BE_ONE_OF: (states, state) => `expected datasource field state to be one of ${states}. Unknown state ${state} received`, - STATE_MUST_NOT_BE_ONE_OF: states => `expected datasource field state not to be of ${states}`, + STATE_MUST_NOT_BE_ONE_OF: states => `expected datasource field state not to be of ${states}` }; /** diff --git a/test/testUtils/createTestConfig.js b/test/testUtils/createTestConfig.js index 883d18d5..dc09a492 100644 --- a/test/testUtils/createTestConfig.js +++ b/test/testUtils/createTestConfig.js @@ -1,5 +1,5 @@ const defaultConfigOptions = { - analytics: false, + analytics: false }; /** diff --git a/test/testUtils/testConstants.js b/test/testUtils/testConstants.js index 59eba07d..35596c36 100644 --- a/test/testUtils/testConstants.js +++ b/test/testUtils/testConstants.js @@ -21,7 +21,7 @@ module.exports = { SHORT: 5000, MEDIUM: 20000, LONG: 50000, - LARGE: 70000, + LARGE: 70000 }, UNIQUE_JOB_SUFFIX_ID, PUBLIC_IDS: { @@ -34,28 +34,28 @@ module.exports = { PUBLIC_ID_6: `${PUBLIC_ID}_6`, PUBLIC_ID_BACKUP_1: `${PUBLIC_ID_PREFIX}backup_1${Date.now()}`, PUBLIC_ID_BACKUP_2: `${PUBLIC_ID_PREFIX}backup_2${Date.now()}`, - PUBLIC_ID_BACKUP_3: `${PUBLIC_ID_PREFIX}backup_3${Date.now()}`, + PUBLIC_ID_BACKUP_3: `${PUBLIC_ID_PREFIX}backup_3${Date.now()}` }, PRESETS: { API_TEST_UPLOAD_PRESET1: `npm_api_test_upload_preset_1_${UNIQUE_JOB_SUFFIX_ID}`, API_TEST_UPLOAD_PRESET2: `npm_api_test_upload_preset_2_${UNIQUE_JOB_SUFFIX_ID}`, API_TEST_UPLOAD_PRESET3: `npm_api_test_upload_preset_3_${UNIQUE_JOB_SUFFIX_ID}`, - API_TEST_UPLOAD_PRESET4: `npm_api_test_upload_preset_4_${UNIQUE_JOB_SUFFIX_ID}`, + API_TEST_UPLOAD_PRESET4: `npm_api_test_upload_preset_4_${UNIQUE_JOB_SUFFIX_ID}` }, TRANSFORMATIONS: { NAMED_TRANSFORMATION: `npm_api_test_transformation_${UNIQUE_JOB_SUFFIX_ID}`, NAMED_TRANSFORMATION2: `npm_api_test_transformation_2_${UNIQUE_JOB_SUFFIX_ID}`, EXPLICIT_TRANSFORMATION_NAME: `c_scale,l_text:Arial_60:${TEST_TAG},w_100`, - EXPLICIT_TRANSFORMATION_NAME2: `c_scale,l_text:Arial_60:${TEST_TAG},w_200`, + EXPLICIT_TRANSFORMATION_NAME2: `c_scale,l_text:Arial_60:${TEST_TAG},w_200` }, TAGS: { UPLOAD_TAGS, TEST_TAG, - SDK_TAG, + SDK_TAG }, URLS: { VIDEO_URL: "http://res.cloudinary.com/demo/video/upload/dog.mp4", - IMAGE_URL: "http://res.cloudinary.com/demo/image/upload/sample", + IMAGE_URL: "http://res.cloudinary.com/demo/image/upload/sample" } }; diff --git a/test/unit/authToken/authTokenImageTag_spec.js b/test/unit/authToken/authTokenImageTag_spec.js index d12819e7..e4a1d570 100644 --- a/test/unit/authToken/authTokenImageTag_spec.js +++ b/test/unit/authToken/authTokenImageTag_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require("expect.js"); @@ -14,7 +14,7 @@ describe("AuthToken tests using image tag", function () { let tag = cloudinary.image("sample.jpg", { sign_url: true, type: "authenticated", - version: "1486020273", + version: "1486020273" }); expect(tag).to.match(//); diff --git a/test/unit/authToken/authTokenURL_spec.js b/test/unit/authToken/authTokenURL_spec.js index a724a733..246b8bdf 100644 --- a/test/unit/authToken/authTokenURL_spec.js +++ b/test/unit/authToken/authTokenURL_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require("expect.js"); @@ -17,7 +17,7 @@ describe("AuthToken tests using cloudinary.url and a private CDN", function () { sign_url: true, resource_type: "image", type: "authenticated", - version: "1486020273", + version: "1486020273" }); expect(url).to.eql("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3"); }); @@ -27,7 +27,7 @@ describe("AuthToken tests using cloudinary.url and a private CDN", function () { sign_url: true, resource_type: "image", type: "public", - version: "1486020273", + version: "1486020273" }); expect(url).to.eql("http://test123-res.cloudinary.com/image/public/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=c2b77d9f81be6d89b5d0ebc67b671557e88a40bcf03dd4a6997ff4b994ceb80e"); }); @@ -35,7 +35,7 @@ describe("AuthToken tests using cloudinary.url and a private CDN", function () { it("Should not add token if signed is false", function () { let url = cloudinary.url("sample.jpg", { type: "authenticated", - version: "1486020273", + version: "1486020273" }); expect(url).to.eql("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg"); }); @@ -45,7 +45,7 @@ describe("AuthToken tests using cloudinary.url and a private CDN", function () { auth_token: false, sign_url: true, type: "authenticated", - version: "1486020273", + version: "1486020273" }); expect(url).to.eql("http://test123-res.cloudinary.com/image/authenticated/s--v2fTPYTu--/v1486020273/sample.jpg"); }); @@ -56,13 +56,13 @@ describe("AuthToken tests using cloudinary.url and a private CDN", function () { auth_token: { key: "CCBB2233FF00", start_time: 222222222, - duration: 100, + duration: 100 }, type: "authenticated", transformation: { crop: "scale", - width: 300, - }, + width: 300 + } }); expect(url).to.eql("http://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=55cfe516530461213fe3b3606014533b1eca8ff60aeab79d1bb84c9322eebc1f"); }); @@ -70,14 +70,14 @@ describe("AuthToken tests using cloudinary.url and a private CDN", function () { it("should compute expiration as start time + duration", function () { let token = { start_time: 11111111, - duration: 300, + duration: 300 }; let url = cloudinary.url("sample.jpg", { sign_url: true, auth_token: token, resource_type: "image", type: "authenticated", - version: "1486020273", + version: "1486020273" }); expect(url).to.eql("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3"); }); diff --git a/test/unit/authToken/authTokenUtils_spec.js b/test/unit/authToken/authTokenUtils_spec.js index fc7d50ff..be5b0b4b 100644 --- a/test/unit/authToken/authTokenUtils_spec.js +++ b/test/unit/authToken/authTokenUtils_spec.js @@ -1,5 +1,5 @@ require('dotenv').load({ - silent: true, + silent: true }); const expect = require("expect.js"); @@ -16,7 +16,7 @@ describe("AuthToken tests using utils.generate_auth_token", function () { let token = utils.generate_auth_token({ start_time: 1111111111, acl: "/image/*", - duration: 300, + duration: 300 }); expect(token).to.eql("__cld_token__=st=1111111111~exp=1111111411~acl=%2fimage%2f*~hmac=1751370bcc6cfe9e03f30dd1a9722ba0f2cdca283fa3e6df3342a00a7528cc51"); @@ -27,7 +27,7 @@ describe("AuthToken tests using utils.generate_auth_token", function () { start_time: 222222222, key: "00112233FF99", duration: 300, - acl: `/*/t_foobar`, + acl: `/*/t_foobar` }); expect(token).to.eql("__cld_token__=st=222222222~exp=222222522~acl=%2f*%2ft_foobar~hmac=8e39600cc18cec339b21fe2b05fcb64b98de373355f8ce732c35710d8b10259f"); diff --git a/test/unit/authToken/utils/commonAuthSetupAndTeardown.js b/test/unit/authToken/utils/commonAuthSetupAndTeardown.js index 4a7bd5f3..a510ea64 100644 --- a/test/unit/authToken/utils/commonAuthSetupAndTeardown.js +++ b/test/unit/authToken/utils/commonAuthSetupAndTeardown.js @@ -27,7 +27,7 @@ function commonAuthSetupAndTeardown(config = {}) { auth_token: { key: AUTH_KEY_1, duration: 300, - start_time: 11111111, + start_time: 11111111 } }, config))); }); diff --git a/test/unit/cache/KeyValueCacheAdapter_spec.js b/test/unit/cache/KeyValueCacheAdapter_spec.js index 2fbccbc4..a1196338 100644 --- a/test/unit/cache/KeyValueCacheAdapter_spec.js +++ b/test/unit/cache/KeyValueCacheAdapter_spec.js @@ -19,12 +19,12 @@ describe("KeyValueCacheAdapter", () => { [ [ // valid values "467d06e5a695b15468f9362e5a58d44de523026b", - ["public_id", "upload", "image", "w_100", "jpg"], + ["public_id", "upload", "image", "w_100", "jpg"] ], [ // allow empty values "1576396c59fc50ac8dc37b75e1184268882c9bc2", - ["public_id", "upload", "image", null, null], - ], + ["public_id", "upload", "image", null, null] + ] ].forEach(([key, args]) => { expect(KeyValueCacheAdapter.generateCacheKey.apply(this, args)).to.eql(key); }); diff --git a/test/unit/tags/image_spec.js b/test/unit/tags/image_spec.js index 15479f62..e96ba9d9 100644 --- a/test/unit/tags/image_spec.js +++ b/test/unit/tags/image_spec.js @@ -17,23 +17,23 @@ describe('image helper', function () { commonTrans = { effect: 'sepia', cloud_name: 'test123', - client_hints: false, + client_hints: false }; commonTransformationStr = 'e_sepia'; customAttributes = { custom_attr1: 'custom_value1', - custom_attr2: 'custom_value2', + custom_attr2: 'custom_value2' }; beforeEach(function () { cloudinary.config(true); // Reset cloudinary.config(createTestConfig({ cloud_name: "test123", - api_secret: "1234", + api_secret: "1234" })); }); it("should generate image", function () { expect(cloudinary.image("hello", { - format: "png", + format: "png" })).to.eql(``); }); it("should accept scale crop and pass width/height to image tag ", function () { @@ -41,38 +41,38 @@ describe('image helper', function () { format: "png", crop: 'scale', width: 100, - height: 100, + height: 100 })).to.eql(``); }); it("should add responsive width transformation", function () { expect(cloudinary.image("hello", { format: "png", - responsive_width: true, + responsive_width: true })).to.eql(``); }); it("should support width auto transformation", function () { expect(cloudinary.image("hello", { format: "png", width: "auto", - crop: "limit", + crop: "limit" })).to.eql(``); }); it("should support dpr auto transformation", function () { expect(cloudinary.image("hello", { format: "png", - dpr: "auto", + dpr: "auto" })).to.eql(``); }); it("should support e_art:incognito transformation", function () { expect(cloudinary.image("hello", { format: "png", - effect: "art:incognito", + effect: "art:incognito" })).to.eql(``); }); it("should not mutate the options argument", function () { var options = { fetch_format: 'auto', - flags: 'progressive', + flags: 'progressive' }; cloudinary.image('hello', options); expect(options.fetch_format).to.eql('auto'); @@ -80,7 +80,7 @@ describe('image helper', function () { }); it("Should consume custom attributes from 'attributes' key", function () { var tag = cloudinary.image('sample.jpg', extend({ - attributes: customAttributes, + attributes: customAttributes }, commonTrans)); Object.entries(customAttributes).forEach(function ([key, value]) { expect(tag).to.contain(`${key}='${value}'`); @@ -99,8 +99,8 @@ describe('image helper', function () { options = extend({}, commonTrans, { alt: "original alt", attributes: { - alt: "updated alt", - }, + alt: "updated alt" + } }); tag = cloudinary.image('sample.jpg', options); expect(tag).to.contain("alt='updated alt'"); @@ -121,7 +121,7 @@ describe('image helper', function () { it("should override responsive", function () { var tag; cloudinary.config({ - responsive: true, + responsive: true }); tag = cloudinary.image('sample.jpg', options); expect(tag).to.match(//); @@ -137,7 +137,7 @@ describe('image helper', function () { cloud_name: "test123", width: "auto", crop: "scale", - client_hints: true, + client_hints: true }); }); describe("as global configuration", function () { @@ -148,7 +148,7 @@ describe('image helper', function () { dpr: "auto", cloud_name: "test123", width: "auto", - crop: "scale", + crop: "scale" }); }); describe("false", function () { @@ -159,7 +159,7 @@ describe('image helper', function () { width: "auto", crop: "scale", cloud_name: "test123", - client_hints: false, + client_hints: false }); expect(tag).to.match(//); expect(tag).to.match(/class=["']cld-responsive["']/); @@ -173,7 +173,7 @@ describe('image helper', function () { dpr: "auto", cloud_name: "test123", width: "auto:breakpoints", - client_hints: true, + client_hints: true }); expect(tag).to.match(srcRegExp("src", "c_scale,dpr_auto,w_auto:breakpoints/sample.jpg")); }); @@ -189,8 +189,8 @@ describe('image helper', function () { var expected, tagWithBreakpoints; tagWithBreakpoints = cloudinary.image('sample.jpg', extend({}, commonTrans, { srcset: { - breakpoints: breakpoints, - }, + breakpoints: breakpoints + } })); expected = getExpectedSrcsetTag('sample.jpg', commonTransformationStr, '', breakpoints); expect(tagWithBreakpoints).to.eql(expected); @@ -200,8 +200,8 @@ describe('image helper', function () { srcset: { min_width: breakpoints[0], max_width: lastBreakpoint, - max_images: breakpoints.length, - }, + max_images: breakpoints.length + } })); var expected = getExpectedSrcsetTag('sample.jpg', commonTransformationStr, '', breakpoints); expect(tag).to.eql(expected); @@ -212,15 +212,15 @@ describe('image helper', function () { srcset: { min_width: breakpoints[0], max_width: lastBreakpoint, - max_images: 1, - }, + max_images: 1 + } })); expected = getExpectedSrcsetTag('sample.jpg', commonTransformationStr, '', [lastBreakpoint]); expect(tag).to.eql(expected); tag = cloudinary.image('sample.jpg', extend({}, commonTrans, { srcset: { - breakpoints: [lastBreakpoint], - }, + breakpoints: [lastBreakpoint] + } })); expect(tag).to.eql(expected); }); @@ -232,9 +232,9 @@ describe('image helper', function () { transformation: { crop: "crop", width: 10, - height: 20, - }, - }, + height: 20 + } + } })); expected = getExpectedSrcsetTag('sample.jpg', commonTransformationStr, 'c_crop,h_20,w_10', breakpoints); expect(tag).to.eql(expected); @@ -244,12 +244,12 @@ describe('image helper', function () { tag = cloudinary.image('sample.jpg', extend({}, commonTrans, { srcset: { breakpoints: breakpoints, - sizes: true, - }, + sizes: true + } })); expectedSizesAttr = '(max-width: 100px) 100px, (max-width: 200px) 200px, ' + '(max-width: 300px) 300px, (max-width: 399px) 399px'; expected = getExpectedSrcsetTag('sample.jpg', commonTransformationStr, '', breakpoints, { - sizes: expectedSizesAttr, + sizes: expectedSizesAttr }); expect(tag).to.eql(expected); }); @@ -257,10 +257,10 @@ describe('image helper', function () { var expected, rawSrcSet, tag; rawSrcSet = "some srcset data as is"; tag = cloudinary.image('sample.jpg', extend({}, commonTrans, { - srcset: rawSrcSet, + srcset: rawSrcSet })); expected = getExpectedSrcsetTag('sample.jpg', commonTransformationStr, '', [], { - srcset: rawSrcSet, + srcset: rawSrcSet }); expect(tag).to.eql(expected); }); @@ -268,9 +268,9 @@ describe('image helper', function () { var expected, tag; tag = cloudinary.image('sample.jpg', extend({}, commonTrans, { width: 500, - height: 500, + height: 500 }, { - srcset: { breakpoints }, + srcset: { breakpoints } })); expected = getExpectedSrcsetTag('sample.jpg', 'e_sepia,h_500,w_500', '', breakpoints); expect(tag).to.eql(expected); @@ -280,8 +280,8 @@ describe('image helper', function () { Cache.set('sample.jpg', {}, BREAKPOINTS); tag = cloudinary.image('sample.jpg', { srcset: { - useCache: true, - }, + useCache: true + } }); srcset = tag.match(/srcset=['"]([^"']+)['"]/)[1]; expect(srcset).to.be.ok(); @@ -295,68 +295,68 @@ describe('image helper', function () { [ [ { - sizes: true, + sizes: true }, - "srcset data not provided", + "srcset data not provided" ], [ { max_width: 300, - max_images: 3, + max_images: 3 }, - "no min_width", + "no min_width" ], [ { min_width: 100, - max_images: 3, + max_images: 3 }, - "no max_width", + "no max_width" ], [ { min_width: 200, max_width: 100, - max_images: 3, + max_images: 3 }, - "min_width > max_width", + "min_width > max_width" ], [ { min_width: 100, - max_width: 300, + max_width: 300 }, - "no max_images", + "no max_images" ], [ { min_width: 100, max_width: 300, - max_images: 0, + max_images: 0 }, - "invalid max_images", + "invalid max_images" ], [ { min_width: 100, max_width: 300, - max_images: -17, + max_images: -17 }, - "invalid max_images", + "invalid max_images" ], [ { min_width: 100, max_width: 300, - max_images: null, + max_images: null }, - "invalid max_images", - ], + "invalid max_images" + ] ].forEach(([srcset, subject]) => { it("Should throw an exception when " + subject, function () { expect(function () { cloudinary.image('sample.jpg', extend({ - srcset: srcset, + srcset: srcset }, commonTrans)); }).to.throwException(); }); @@ -365,9 +365,9 @@ describe('image helper', function () { it("Should throw InvalidArgumentException on invalid values", function () { let tag = cloudinary.image('sample.jpg', extend({}, commonTrans, { width: 500, - height: 500, + height: 500 }, { - srcset: { breakpoints }, + srcset: { breakpoints } })); let expected = getExpectedSrcsetTag('sample.jpg', 'e_sepia,h_500,w_500', '', breakpoints); expect(tag).to.eql(expected); diff --git a/test/unit/tags/video_spec.js b/test/unit/tags/video_spec.js index 750fc9af..d0237f5a 100644 --- a/test/unit/tags/video_spec.js +++ b/test/unit/tags/video_spec.js @@ -16,7 +16,7 @@ describe("video tag helper", function () { cloudinary.config(true); // Reset cloudinary.config(createTestConfig({ cloud_name: "test123", - api_secret: "1234", + api_secret: "1234" })); }); it("should generate video tag", function () { @@ -31,7 +31,7 @@ describe("video tag helper", function () { loop: true, muted: "true", preload: true, - style: "border: 1px", + style: "border: 1px" })).to.eql(`"); }); it("should generate video tag with various attributes", function () { @@ -41,11 +41,11 @@ describe("video tag helper", function () { html_height: "100", html_width: "200", video_codec: { - codec: "h264", + codec: "h264" }, audio_codec: "acc", start_offset: 3, - keyframe_interval: "2.0", + keyframe_interval: "2.0" }; expected_url = VIDEO_UPLOAD_PATH + "ac_acc,ki_2.0,so_3,vc_h264/movie"; expect(cloudinary.video("movie", options)).to.eql(``); @@ -66,17 +66,17 @@ describe("video tag helper", function () { expected_url = VIDEO_UPLOAD_PATH + "movie"; fallback = "Cannot display video"; expect(cloudinary.video("movie", { - fallback_content: fallback, + fallback_content: fallback }), `"); expect(cloudinary.video("movie", { fallback_content: fallback, - source_types: "mp4", + source_types: "mp4" })).to.eql(`"); }); it("should generate video tag with source types", function () { var expected_url = VIDEO_UPLOAD_PATH + "movie"; expect(cloudinary.video("movie", { - source_types: ['ogv', 'mp4'], + source_types: ['ogv', 'mp4'] })).to.eql(`"); }); it("should generate video tag with source transformation", function () { @@ -88,32 +88,32 @@ describe("video tag helper", function () { width: 100, crop: "scale", transformation: { - 'quality': 50, + 'quality': 50 }, source_transformation: { 'ogv': { - 'quality': 70, + 'quality': 70 }, 'mp4': { - 'quality': 30, - }, - }, + 'quality': 30 + } + } })).to.eql(`"); expect(cloudinary.video("movie", { width: 100, crop: "scale", transformation: { - 'quality': 50, + 'quality': 50 }, source_transformation: { 'ogv': { - 'quality': 70, + 'quality': 70 }, 'mp4': { - 'quality': 30, - }, + 'quality': 30 + } }, - source_types: ['webm', 'mp4'], + source_types: ['webm', 'mp4'] })).to.eql(`"); }); it("should generate video tag with configurable poster", function () { @@ -122,37 +122,37 @@ describe("video tag helper", function () { expected_poster_url = 'http://image/somewhere.jpg'; expect(cloudinary.video("movie", { poster: expected_poster_url, - source_types: "mp4", + source_types: "mp4" })).to.eql(``); expected_poster_url = VIDEO_UPLOAD_PATH + "g_north/movie.jpg"; expect(cloudinary.video("movie", { poster: { - 'gravity': 'north', + 'gravity': 'north' }, - source_types: "mp4", + source_types: "mp4" })).to.eql(``); expected_poster_url = DEFAULT_UPLOAD_PATH + "g_north/my_poster.jpg"; expect(cloudinary.video("movie", { poster: { 'gravity': 'north', 'public_id': 'my_poster', - 'format': 'jpg', + 'format': 'jpg' }, - source_types: "mp4", + source_types: "mp4" })).to.eql(``); expect(cloudinary.video("movie", { poster: "", - source_types: "mp4", + source_types: "mp4" })).to.eql(``); expect(cloudinary.video("movie", { poster: false, - source_types: "mp4", + source_types: "mp4" })).to.eql(``); }); it("should not mutate the options argument", function () { var options = { video_codec: 'auto', - autoplay: true, + autoplay: true }; cloudinary.video('hello', options); expect(options.video_codec).to.eql('auto'); @@ -175,15 +175,15 @@ describe("video tag helper", function () { it('should generate video tag with given custom sources', function() { var custom_sources = [ { - type: 'mp4', + type: 'mp4' }, { - type: 'webm', - }, + type: 'webm' + } ]; expect( cloudinary.video('movie', { - sources: custom_sources, + sources: custom_sources }) ).to.eql( `