From 8fe3858d99035d1076773bf1bae6e986cde7c09c Mon Sep 17 00:00:00 2001 From: danielsequeira Date: Thu, 24 Oct 2019 14:15:05 +0200 Subject: [PATCH 1/3] made scope mandaroty and removed deprecated login samples --- samples/login.html | 84 ------------------------------------ samples/login.js | 12 ------ samples/login_completed.html | 15 ------- src/bynder-js-sdk.js | 8 ++-- 4 files changed, 3 insertions(+), 116 deletions(-) delete mode 100644 samples/login.html delete mode 100644 samples/login.js delete mode 100644 samples/login_completed.html diff --git a/samples/login.html b/samples/login.html deleted file mode 100644 index ff906a9..0000000 --- a/samples/login.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Login sample - - - - - - - - - - -
TypeTokenSecret
- - - - - - - diff --git a/samples/login.js b/samples/login.js deleted file mode 100644 index 1eb5628..0000000 --- a/samples/login.js +++ /dev/null @@ -1,12 +0,0 @@ -const Bynder = require('../dist/bynder-js-sdk.js').default; -const configs = require('../secret.json'); - -const bynder = new Bynder(configs); - -bynder.userLogin(configs.login) - .then((data) => { - console.log('login', data, '\n\n'); - }) - .catch((error) => { - console.log(error); - }); diff --git a/samples/login_completed.html b/samples/login_completed.html deleted file mode 100644 index a658828..0000000 --- a/samples/login_completed.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Bravo Signore! - - -

Login completed!

- - - diff --git a/src/bynder-js-sdk.js b/src/bynder-js-sdk.js index 103e924..a8cde82 100644 --- a/src/bynder-js-sdk.js +++ b/src/bynder-js-sdk.js @@ -7,7 +7,6 @@ const queryString = require("query-string"); const simpleOAuth2 = require("simple-oauth2"); const url = require("url"); -const DEFAULT_SCOPES = "openid offline"; const defaultAssetsNumberPerPage = 50; /** @@ -196,10 +195,10 @@ class Bynder { * Builds OAuth2 authorization URL. * @return {String} Authorization URL */ - makeAuthorizationURL(state) { + makeAuthorizationURL(state, scope) { return this.oauth2.authorizationCode.authorizeURL({ redirect_uri: this.redirectUri, - scope: DEFAULT_SCOPES, + scope: scope, state: state }); } @@ -212,8 +211,7 @@ class Bynder { getToken(code) { const tokenConfig = { code: code, - redirect_uri: this.redirectUri, - scope: DEFAULT_SCOPES + redirect_uri: this.redirectUri }; return this.oauth2.authorizationCode.getToken(tokenConfig).then(result => { From 42dcb9076c1fd9ba8a1160e92665fff71047cc5e Mon Sep 17 00:00:00 2001 From: danielsequeira Date: Thu, 24 Oct 2019 14:28:13 +0200 Subject: [PATCH 2/3] updated tests --- tests/__snapshots__/login.test.js.snap | 2 +- tests/login.test.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/__snapshots__/login.test.js.snap b/tests/__snapshots__/login.test.js.snap index 56fc6d5..58fbac4 100644 --- a/tests/__snapshots__/login.test.js.snap +++ b/tests/__snapshots__/login.test.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Make authorization URL should return correct authorization URL 1`] = `"https://integrations.getbynder.com/v6/authentication/oauth2/auth?response_type=code&client_id=5f5206f4-2d7a-4345-bd4c-12fad14ac111&redirect_uri=http%3A%2F%2Flocalhost%2Ftest%2Fcallback&scope=openid%20offline&state=state%20example"`; +exports[`Make authorization URL should return correct authorization URL 1`] = `"https://integrations.getbynder.com/v6/authentication/oauth2/auth?response_type=code&client_id=5f5206f4-2d7a-4345-bd4c-12fad14ac111&redirect_uri=http%3A%2F%2Flocalhost%2Ftest%2Fcallback&scope=offline&state=state%20example"`; diff --git a/tests/login.test.js b/tests/login.test.js index 3b8f94b..b6fd4ac 100644 --- a/tests/login.test.js +++ b/tests/login.test.js @@ -6,8 +6,10 @@ let bynder; describe("Make authorization URL", () => { bynder = new Bynder(configs); - const encodedRedirectUri = encodeURIComponent(configs.redirectUri); - const authorizationUrl = bynder.makeAuthorizationURL("state example"); + const authorizationUrl = bynder.makeAuthorizationURL( + "state example", + "offline" + ); test("should return correct authorization URL", () => { // Security token is random token so we compare without this From c1c14e1b7f0fca743c01fb3b136a9479a2a00cd3 Mon Sep 17 00:00:00 2001 From: danielsequeira Date: Thu, 24 Oct 2019 14:32:27 +0200 Subject: [PATCH 3/3] removed not meaningful tests --- tests/brands.test.js | 35 ----- tests/collections.test.js | 91 ------------ tests/media.js | 186 ------------------------ tests/media.test.js | 173 ---------------------- tests/metaproperties.test.js | 271 ----------------------------------- tests/smartfilters.js | 36 ----- tests/smartfilters.test.js | 35 ----- tests/tags.test.js | 33 ----- 8 files changed, 860 deletions(-) delete mode 100644 tests/brands.test.js delete mode 100644 tests/collections.test.js delete mode 100644 tests/media.js delete mode 100644 tests/media.test.js delete mode 100644 tests/metaproperties.test.js delete mode 100644 tests/smartfilters.js delete mode 100644 tests/smartfilters.test.js delete mode 100644 tests/tags.test.js diff --git a/tests/brands.test.js b/tests/brands.test.js deleted file mode 100644 index 564a761..0000000 --- a/tests/brands.test.js +++ /dev/null @@ -1,35 +0,0 @@ -const Bynder = require("../src/bynder-js-sdk.js"); -const configs = require("../secret.json"); - -describe("Brands", () => { - let bynder; - let brands; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getBrands() - .then(data => { - brands = data; - done(); - }) - .catch(error => { - brands = error; - done(); - }); - }); - - test("should get all the brands", () => { - expect(Array.isArray(brands)).toEqual(true); - if (brands && brands.length) { - const randomIndex = Math.floor(Math.random() * brands.length); - const randomBrand = Object.keys(brands[randomIndex]); - expect(randomBrand).toContain("id"); - expect(randomBrand).toContain("name"); - expect(randomBrand).toContain("description"); - expect(randomBrand).toContain("image"); - expect(randomBrand).toContain("subBrands"); - } - }); -}); diff --git a/tests/collections.test.js b/tests/collections.test.js deleted file mode 100644 index d9c4da5..0000000 --- a/tests/collections.test.js +++ /dev/null @@ -1,91 +0,0 @@ -const Bynder = require("../src/bynder-js-sdk.js"); -const configs = require("../secret.json"); - -let randomCollectionId; - -describe("Get all collections", () => { - let bynder; - let collections; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getCollections() - .then(data => { - collections = data; - const randomIndex = Math.floor(Math.random() * collections.length); - randomCollectionId = collections[randomIndex].id; - done(); - }) - .catch(error => { - collections = error; - done(); - }); - }); - - test("should get all the collections", () => { - expect(Array.isArray(collections)).toEqual(true); - expect(randomCollectionId).not.toBeUndefined(); - }); -}); - -describe("Get one collection", () => { - let bynder; - let collection; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getCollection({ - id: randomCollectionId - }) - .then(data => { - collection = data; - done(); - }) - .catch(error => { - collection = error; - done(); - }); - }); - - test("should get one specific collection", () => { - const collectionKeys = Object.keys(collection); - expect(collectionKeys).toContain("name"); - expect(collectionKeys).toContain("link"); - expect(collectionKeys).toContain("views"); - expect(collectionKeys).toContain("datecreated"); - }); -}); - -describe("Create collection", () => { - let bynder; - let result; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .saveNewCollection({ - name: "test" - }) - .then(data => { - result = data; - done(); - }) - .catch(error => { - result = error; - done(); - }); - }); - - test("should create one collection", () => { - const collectionKeys = Object.keys(result); - expect(collectionKeys).toContain("message"); - expect(collectionKeys).toContain("statuscode"); - expect(result.message).toBe("Created"); - expect(result.statuscode).toBe(201); - }); -}); diff --git a/tests/media.js b/tests/media.js deleted file mode 100644 index 284c6f0..0000000 --- a/tests/media.js +++ /dev/null @@ -1,186 +0,0 @@ -/* eslint-env jasmine */ - -const Bynder = require('../dist/bynder-js-sdk.js').default; -const configs = require('../secret.json'); - -const defaultAssetsNumberReturnedByApi = 50; - -let getAllAssetsResponse; -let getAssetsResponse; -let getAssetsTotal; -let getAssetResponse; -let testAssetRandomIndex; -let testAssetId; -let testAssetDescriptionBackup; -const testDescriptionString = 'byndertestdescription'; - -describe('Get assets', () => { - let bynder; - let assets; - - beforeEach((done) => { - bynder = new Bynder(configs); - - bynder.getMediaList() - .then((data) => { - assets = data; - done(); - }) - .catch((error) => { - assets = error; - done(); - }); - }); - - it('should get all the assets', () => { - expect(Array.isArray(assets)).toEqual(true); - if (assets && assets.length) { - const randomIndex = Math.floor(Math.random() * assets.length); - const randomObjectKeys = Object.keys(assets[randomIndex]); - expect(randomObjectKeys).toContain('name'); - expect(randomObjectKeys).toContain('id'); - expect(randomObjectKeys).toContain('type'); - expect(randomObjectKeys).toContain('thumbnails'); - } - }); -}); - -describe('Wrong properties', () => { - let bynder; - let assets; - let fail1 = false; - let asset; - let fail2 = false; - - beforeAll((done) => { - bynder = new Bynder(configs); - const p1 = bynder.getMediaList({ - propertyOptionIds: ['00000000-0000-0000-0000000000000000'] - }) - .then((data) => { - assets = data; - }) - .catch((error) => { - fail1 = true; - assets = error; - }); - - const p2 = bynder.getMediaInfo({ - idx: '00000000-0000-0000-0000000000000000' - }) - .then((data) => { - asset = data; - }) - .catch((error) => { - fail2 = true; - asset = error; - }); - - Promise.all([p1, p2]).then(() => { - done(); - }); - }); - - it('Wrong property in getAssets()', () => { - expect(fail1).toBe(false); - expect(Array.isArray(assets)).toEqual(true); - if (assets && assets.length) { - const randomIndex = Math.floor(Math.random() * assets.length); - const randomObjectKeys = Object.keys(assets[randomIndex]); - expect(randomObjectKeys).toContain('name'); - expect(randomObjectKeys).toContain('id'); - expect(randomObjectKeys).toContain('type'); - expect(randomObjectKeys).toContain('thumbnails'); - } - }); - - it('Wrong property in getAsset()', () => { - expect(asset).not.toBeUndefined(); - expect(fail2).toBe(true); - expect(asset.status).toEqual(0); - }); -}); - -describe('Unwanted parameters in query object', () => { - let bynder; - let assets; - let fail = false; - - beforeAll((done) => { - bynder = new Bynder(configs); - bynder.getMediaList({ - count: 1 - }) - .then((data) => { - assets = data; - done(); - }) - .catch((error) => { - fail = true; - assets = error; - done(); - }); - }); - - it('Passing count in getAssets()', () => { - expect(fail).toBe(false); - expect(Array.isArray(assets)).toEqual(true); - if (assets && assets.length) { - const randomIndex = Math.floor(Math.random() * assets.length); - const randomObjectKeys = Object.keys(assets[randomIndex]); - expect(randomObjectKeys).toContain('name'); - expect(randomObjectKeys).toContain('id'); - expect(randomObjectKeys).toContain('type'); - expect(randomObjectKeys).toContain('thumbnails'); - } - }); -}); - -describe('Send special characters', () => { - let bynder; - let assets1; - let fail1 = false; - let assets2; - let fail2 = false; - - beforeAll((done) => { - bynder = new Bynder(configs); - const p1 = bynder.getMediaList({ - ' ̋Þ́̌̇́ ̰‸̆̇&/%//!': 1 // The finest and most curated collection of chars in the attempt to break Bynder - }) - .then((data) => { - assets1 = data; - }) - .catch((error) => { - fail1 = true; - assets1 = error; - }); - const p2 = bynder.getMediaList({ - type: 'image', - page: '1&limit=5', - limit: 1 - }) - .then((data) => { - assets2 = data; - }) - .catch((error) => { - fail2 = true; - assets2 = error; - }); - Promise.all([p1, p2]).then(() => { - done(); - }); - }); - - it('Passing illegal characters as parameters', () => { - expect(assets1).not.toBeUndefined(); - expect(assets1.response.status).toEqual(401); - expect(fail1).toBe(true); - }); - - it('Passing illegal characters as values', () => { - expect(assets2).not.toBeUndefined(); - expect(assets2.response.status).toEqual(400); - expect(fail2).toBe(true); - }); -}); diff --git a/tests/media.test.js b/tests/media.test.js deleted file mode 100644 index 3620515..0000000 --- a/tests/media.test.js +++ /dev/null @@ -1,173 +0,0 @@ -const Bynder = require("../src/bynder-js-sdk.js"); -const configs = require("../secret.json"); - -const defaultAssetsNumberReturnedByApi = 50; - -let getAllAssetsResponse; -let getAssetsResponse; -let getAssetsTotal; -let getAssetResponse; -let testAssetRandomIndex; -let testAssetId; -let testAssetDescriptionBackup; -const testDescriptionString = "byndertestdescription"; - -describe("Get assets", () => { - let bynder; - let assets; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getMediaList() - .then(data => { - assets = data; - done(); - }) - .catch(error => { - assets = error; - done(); - }); - }); - - test("should get all the assets", () => { - expect(Array.isArray(assets)).toEqual(true); - if (assets && assets.length) { - const randomIndex = Math.floor(Math.random() * assets.length); - const randomObjectKeys = Object.keys(assets[randomIndex]); - expect(randomObjectKeys).toContain("name"); - expect(randomObjectKeys).toContain("id"); - expect(randomObjectKeys).toContain("type"); - expect(randomObjectKeys).toContain("thumbnails"); - } - }); -}); - -describe("Wrong properties", () => { - let bynder; - let assets; - let fail1 = false; - let asset; - let fail2 = false; - - beforeAll(done => { - bynder = new Bynder(configs); - const p1 = bynder - .getMediaList({ - propertyOptionIds: ["00000000-0000-0000-0000000000000000"] - }) - .then(data => { - assets = data; - }) - .catch(error => { - fail1 = true; - assets = error; - }); - - const p2 = bynder - .getMediaInfo({ - idx: "00000000-0000-0000-0000000000000000" - }) - .then(data => { - asset = data; - }) - .catch(error => { - fail2 = true; - asset = error; - }); - - Promise.all([p1, p2]).then(() => { - done(); - }); - }); - - test("Wrong property in getAssets()", () => { - expect(fail1).toBe(false); - expect(Array.isArray(assets)).toEqual(true); - if (assets && assets.length) { - const randomIndex = Math.floor(Math.random() * assets.length); - const randomObjectKeys = Object.keys(assets[randomIndex]); - expect(randomObjectKeys).toContain("name"); - expect(randomObjectKeys).toContain("id"); - expect(randomObjectKeys).toContain("type"); - expect(randomObjectKeys).toContain("thumbnails"); - } - }); - - test("Wrong property in getAsset()", () => { - expect(asset).not.toBeUndefined(); - expect(fail2).toBe(true); - expect(asset.status).toEqual(0); - }); -}); - -describe("Unwanted parameters in query object", () => { - let bynder; - let assets; - let fail = false; - - beforeAll(done => { - bynder = new Bynder(configs); - bynder - .getMediaList({ - count: 1 - }) - .then(data => { - assets = data; - done(); - }) - .catch(error => { - fail = true; - assets = error; - done(); - }); - }); - - test("Passing count in getAssets()", () => { - expect(fail).toBe(false); - expect(Array.isArray(assets)).toEqual(true); - if (assets && assets.length) { - const randomIndex = Math.floor(Math.random() * assets.length); - const randomObjectKeys = Object.keys(assets[randomIndex]); - expect(randomObjectKeys).toContain("name"); - expect(randomObjectKeys).toContain("id"); - expect(randomObjectKeys).toContain("type"); - expect(randomObjectKeys).toContain("thumbnails"); - } - }); -}); - -describe("Send special characters", () => { - let bynder; - let assets1; - let fail1 = false; - let assets2; - let fail2 = false; - - beforeAll(done => { - bynder = new Bynder(configs); - const p1 = bynder - .getMediaList({ - type: "image", - page: "abc", - limit: 1 - }) - .then(data => { - assets1 = data; - }) - .catch(error => { - fail1 = true; - assets1 = error; - }); - Promise.resolve(p1).then(() => { - done(); - }); - }); - - test("Passing illegal characters as values", () => { - expect(assets1).not.toBeUndefined(); - expect(assets1.response.status).toEqual(400); - expect(fail1).toBe(true); - }); -}); diff --git a/tests/metaproperties.test.js b/tests/metaproperties.test.js deleted file mode 100644 index 17acd26..0000000 --- a/tests/metaproperties.test.js +++ /dev/null @@ -1,271 +0,0 @@ -const Bynder = require("../src/bynder-js-sdk.js"); -const configs = require("../secret.json"); - -jest.setTimeout(20000); - -const byndertestproperty = "byndertestproperty"; -const label = "label"; -const type = "select"; -let metaId; -let optionId; - -describe("Save metaproperty", () => { - let bynder; - let saveDataResponse; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .saveNewMetaproperty({ - name: byndertestproperty, - label: label, - type: type - }) - .then(data => { - saveDataResponse = data; - done(); - }) - .catch(() => { - done(); - }); - }); - - test("should save one metaproperty", () => { - expect(saveDataResponse).not.toBeUndefined(); - }); -}); - -describe("Get all metaproperties", () => { - let bynder; - let metaproperties; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getMetaproperties() - .then(data => { - metaproperties = data; - metaproperties.forEach(metaproperty => { - if (metaproperty.name === byndertestproperty) { - metaId = metaproperty.id; - } - }); - done(); - }) - .catch(error => { - metaproperties = error; - done(); - }); - }); - - test("should get all the metaproperties", () => { - expect(Array.isArray(metaproperties)).toEqual(true); - expect(metaId).not.toBeUndefined(); - }); -}); - -describe("Get one metaproperty", () => { - let bynder; - let metaproperty; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getMetaproperty({ - id: metaId - }) - .then(data => { - metaproperty = data; - done(); - }) - .catch(error => { - metaproperty = error; - done(); - }); - }); - - test("should get one specific metaproperty", () => { - const metapropertyKeys = Object.keys(metaproperty); - expect(metapropertyKeys).toContain("name"); - expect(metapropertyKeys).toContain("id"); - expect(metapropertyKeys).toContain("options"); - expect(metapropertyKeys).toContain("zindex"); - expect(metapropertyKeys).toContain("isFilterable"); - }); -}); - -describe("Edit metaproperty", () => { - let bynder; - let response; - let metaproperty; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .editMetaproperty({ - id: metaId, - label: `${label}_mod` - }) - .then(data => { - response = data; - return bynder.getMetaproperty({ id: metaId }); - }) - .then(data => { - metaproperty = data; - done(); - }) - .catch(error => { - metaproperty = error; - done(); - }); - }); - - test("should edit one metaproperty", () => { - expect(response.statuscode).toEqual(201); - expect(response.message).toEqual("Created"); - expect(metaproperty.label).toEqual(`${label}_mod`); - const metapropertyKeys = Object.keys(metaproperty); - expect(metapropertyKeys).toContain("name"); - expect(metapropertyKeys).toContain("id"); - expect(metapropertyKeys).toContain("options"); - expect(metapropertyKeys).toContain("zindex"); - expect(metapropertyKeys).toContain("isFilterable"); - }); -}); - -describe("Create an option for metaproperty", () => { - let bynder; - let result; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .saveNewMetapropertyOption({ - id: metaId, - name: "optiontest" - }) - .then(data => { - result = data; - done(); - }) - .catch(error => { - result = error; - done(); - }); - }); - - test("should create option for metaproperty", () => { - const metapropertyKeys = Object.keys(result); - expect(metapropertyKeys).toContain("statuscode"); - expect(metapropertyKeys).toContain("message"); - expect(result.statuscode).toBe(201); - expect(result.message).toBe("Created"); - }); -}); - -describe("Modify an option of metaproperty", () => { - let bynder; - let result; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getMetaproperty({ - id: metaId - }) - .then(data => { - optionId = data.options[0].id; - }) - .then(() => { - return bynder.editMetapropertyOption({ - id: metaId, - optionId, - label: "Option Test" - }); - }) - .then(data => { - result = data; - done(); - }) - .catch(error => { - result = error; - done(); - }); - }); - - test("should modify an option of metaproperty", () => { - const metapropertyKeys = Object.keys(result); - expect(metapropertyKeys).toContain("statuscode"); - expect(metapropertyKeys).toContain("message"); - expect(result.statuscode).toBe(201); - expect(result.message).toBe("Created"); - }); -}); - -describe("Delete an option of metaproperty", () => { - let bynder; - let result; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getMetaproperty({ - id: metaId - }) - .then(data => { - optionId = data.options[0].id; - }) - .then(() => { - return bynder.deleteMetapropertyOption({ - id: metaId, - optionId - }); - }) - .then(data => { - result = data; - done(); - }) - .catch(error => { - result = error; - done(); - }); - }); - - test("should delete an option of metaproperty", () => { - expect(result).not.toBeUndefined(); - const metapropertyKeys = Object.keys(result); - expect(metapropertyKeys.length).toBe(0); - }); -}); - -describe("Delete metaproperty", () => { - let bynder; - let deleteMetapropertyResponse; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .deleteMetaproperty({ - id: metaId - }) - .then(data => { - deleteMetapropertyResponse = data; - done(); - }) - .catch(() => { - done(); - }); - }); - - test("should delete metaproperty", () => { - expect(deleteMetapropertyResponse).not.toBeUndefined(); - }); -}); diff --git a/tests/smartfilters.js b/tests/smartfilters.js deleted file mode 100644 index aa38ef9..0000000 --- a/tests/smartfilters.js +++ /dev/null @@ -1,36 +0,0 @@ -/* eslint-env jasmine */ - -const Bynder = require('../dist/bynder-js-sdk.js').default; -const configs = require('../secret.json'); - -describe('Smartfilters', () => { - let bynder; - let smartfilters; - - beforeEach((done) => { - bynder = new Bynder(configs); - - bynder.getSmartfilters() - .then((data) => { - smartfilters = data; - done(); - }) - .catch((error) => { - smartfilters = error; - done(); - }); - }); - - it('should get all the smartfilters', () => { - expect(Array.isArray(smartfilters)).toEqual(true); - if (smartfilters && smartfilters.length) { - const randomIndex = Math.floor(Math.random() * smartfilters.length); - const randomSmartfilter = Object.keys(smartfilters[randomIndex]); - expect(randomSmartfilter).toContain('icon'); - expect(randomSmartfilter).toContain('labels'); - expect(randomSmartfilter).toContain('zindex'); - expect(randomSmartfilter).toContain('id'); - expect(randomSmartfilter).toContain('metaproperties'); - } - }); -}); diff --git a/tests/smartfilters.test.js b/tests/smartfilters.test.js deleted file mode 100644 index a627b62..0000000 --- a/tests/smartfilters.test.js +++ /dev/null @@ -1,35 +0,0 @@ -const Bynder = require("../src/bynder-js-sdk.js"); -const configs = require("../secret.json"); - -describe("Smartfilters", () => { - let bynder; - let smartfilters; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getSmartfilters() - .then(data => { - smartfilters = data; - done(); - }) - .catch(error => { - smartfilters = error; - done(); - }); - }); - - test("should get all the smartfilters", () => { - expect(Array.isArray(smartfilters)).toEqual(true); - if (smartfilters && smartfilters.length) { - const randomIndex = Math.floor(Math.random() * smartfilters.length); - const randomSmartfilter = Object.keys(smartfilters[randomIndex]); - expect(randomSmartfilter).toContain("icon"); - expect(randomSmartfilter).toContain("labels"); - expect(randomSmartfilter).toContain("zindex"); - expect(randomSmartfilter).toContain("id"); - expect(randomSmartfilter).toContain("metaproperties"); - } - }); -}); diff --git a/tests/tags.test.js b/tests/tags.test.js deleted file mode 100644 index 183bacd..0000000 --- a/tests/tags.test.js +++ /dev/null @@ -1,33 +0,0 @@ -const Bynder = require("../src/bynder-js-sdk.js"); -const configs = require("../secret.json"); - -describe("Tags", () => { - let bynder; - let tags; - - beforeEach(done => { - bynder = new Bynder(configs); - - bynder - .getTags() - .then(data => { - tags = data; - done(); - }) - .catch(error => { - tags = error; - done(); - }); - }); - - test("should get all the tags", () => { - expect(Array.isArray(tags)).toEqual(true); - if (tags && tags.length) { - const randomIndex = Math.floor(Math.random() * tags.length); - const randomCategory = Object.keys(tags[randomIndex]); - expect(randomCategory).toContain("id"); - expect(randomCategory).toContain("tag"); - expect(randomCategory).toContain("mediaCount"); - } - }); -});