diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 6cc74550..dd260558 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: '20.x' + node-version: '22.x' registry-url: 'https://registry.npmjs.org' - run: npm ci - run: npm publish @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: '20.x' + node-version: '22.x' registry-url: 'https://npm.pkg.github.com' scope: '@contentstack' - run: npm ci diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 788f8d28..27062c53 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 # checkout the repo - uses: actions/setup-node@v3 with: - node-version: '20.x' + node-version: '22.x' registry-url: 'https://registry.npmjs.org' - run: npm ci # install packages - run: npm run test:unit:report:json # run tests (configured to use jest-junit reporter) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f545f6..30e7d449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## [v1.18.2](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.2) (2024-10-3) + - Fix + - Variants testcases Added + - Node v22 support ## [v1.18.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.18.1) (2024-09-27) - Fix - Variants testcases Added diff --git a/lib/stack/variantGroup/index.js b/lib/stack/variantGroup/index.js index b036c5bd..8f3b535b 100644 --- a/lib/stack/variantGroup/index.js +++ b/lib/stack/variantGroup/index.js @@ -59,22 +59,6 @@ export function VariantGroup (http, data = {}) { */ this.delete = deleteEntity(http) - /** - * @description The fetch VariantGroup call fetches VariantGroup details. - * @memberof VariantGroup - * @func fetch - * @returns {Promise} Promise for VariantGroup instance - * @param {Int} version Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack. - * @example - * import * as contentstack from '@contentstack/management' - * const client = contentstack.client() - * - * client.stack({ api_key: 'api_key'}).VariantGroup('variant_group_uid').fetch() - * .then((variant_group) => console.log(variant_group)) - * - */ - // this.fetch = fetch(http, 'variant_group') - /** * @description Content type defines the structure or schema of a page or a section of your web or mobile property. * @param {String} uid The UID of the ContentType you want to get details. @@ -115,7 +99,24 @@ export function VariantGroup (http, data = {}) { * client.stack().VariantGroup().create({ variant_group } ) * .then((variant_group) => console.log(variant_group)) */ - this.create = create({ http: http }) + this.create = async (data) => { + try { + const response = await http.post(`${this.urlPath}`, + data , + { + headers: { + ...cloneDeep(this.stackHeaders) + } + }) + if (response.data) { + return response.data + } else { + return error(response) + } + } catch (err) { + return error(err) + } + } /** * @description The Query on Variant Groups will allow to fetch details of all or specific Variant Groups diff --git a/lib/stack/variantGroup/variants/index.js b/lib/stack/variantGroup/variants/index.js index b368ae3c..cfbb2a74 100644 --- a/lib/stack/variantGroup/variants/index.js +++ b/lib/stack/variantGroup/variants/index.js @@ -60,7 +60,25 @@ export function Variants(http, data = {}) { * .then((variants) => console.log(variants)) * */ - this.fetch = fetch(http, 'variants') + this.fetch = async (param = {}) => { + try { + const headers = { + headers: { ...cloneDeep(this.stackHeaders) }, + params: { + ...cloneDeep(param) + } + } || {} + + const response = await http.get(this.urlPath, headers) + if (response.data) { + return response.data + } else { + throw error(response) + } + } catch (err) { + error(err) + } + } /** * @description The Delete Variant call is used to delete an existing Variant permanently from your Stack. @@ -98,7 +116,24 @@ export function Variants(http, data = {}) { * client.stack().VariantGroup('variant_group_uid').variants().create({ data } ) * .then((variants) => console.log(variants)) */ - this.create = create({ http: http }) + this.create = async (data) => { + try { + const response = await http.post(`${this.urlPath}`, + data , + { + headers: { + ...cloneDeep(this.stackHeaders) + } + }) + if (response.data) { + return response.data + } else { + return error(response) + } + } catch (err) { + return error(err) + } + } /** * @description The Query on Variant Groups will allow to fetch details of all or specific Variant Groups diff --git a/lib/stack/variants/index.js b/lib/stack/variants/index.js index cb630073..7df5e02a 100644 --- a/lib/stack/variants/index.js +++ b/lib/stack/variants/index.js @@ -44,7 +44,25 @@ export function Variants (http, data) { * .then((variants) => console.log(variants)) * */ - this.fetch = fetch(http, 'variants') + this.fetch = async (param = {}) => { + try { + const headers = { + headers: { ...cloneDeep(this.stackHeaders) }, + params: { + ...cloneDeep(param) + } + } || {} + + const response = await http.get(this.urlPath, headers) + if (response.data) { + return response.data + } else { + throw error(response) + } + } catch (err) { + error(err) + } + } } else { /** * @description The Create an variants call creates a new variants. @@ -68,7 +86,24 @@ export function Variants (http, data) { * client.stack().variants().create({ variants }) * .then((variants) => console.log(variants)) */ - this.create = create({ http }) + this.create = async (data) => { + try { + const response = await http.post(`${this.urlPath}`, + data , + { + headers: { + ...cloneDeep(this.stackHeaders) + } + }) + if (response.data) { + return response.data + } else { + return error(response) + } + } catch (err) { + return error(err) + } + } /** * @description The Query on Variants will allow to fetch details of all or specific Variants. diff --git a/package-lock.json b/package-lock.json index c4c16e5a..1a2b5558 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@contentstack/management", - "version": "1.18.1", + "version": "1.18.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.18.1", + "version": "1.18.2", "license": "MIT", "dependencies": { "axios": "^1.7.4", @@ -3405,32 +3405,10 @@ "@types/node": "*" } }, - "node_modules/@types/eslint": { - "version": "8.56.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", - "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, - "node_modules/@types/eslint-scope": { - "version": "3.7.7", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz", - "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/eslint": "*", - "@types/estree": "*" - } - }, "node_modules/@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", "dev": true, "license": "MIT" }, @@ -5017,9 +4995,9 @@ "license": "MIT" }, "node_modules/body-parser": { - "version": "1.20.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", - "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", "dev": true, "license": "MIT", "dependencies": { @@ -5031,7 +5009,7 @@ "http-errors": "2.0.0", "iconv-lite": "0.4.24", "on-finished": "2.4.1", - "qs": "6.11.0", + "qs": "6.13.0", "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" @@ -5058,22 +5036,6 @@ "dev": true, "license": "MIT" }, - "node_modules/body-parser/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -6003,9 +5965,9 @@ } }, "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", "dev": true, "license": "MIT", "engines": { @@ -6013,9 +5975,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.0.tgz", - "integrity": "sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==", + "version": "5.17.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", + "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", "dev": true, "license": "MIT", "dependencies": { @@ -6869,38 +6831,38 @@ } }, "node_modules/express": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", - "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", + "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", "dev": true, "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.2", + "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.2.0", + "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", + "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", + "path-to-regexp": "0.1.10", "proxy-addr": "~2.0.7", - "qs": "6.11.0", + "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", + "send": "0.19.0", + "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -6929,28 +6891,12 @@ "license": "MIT" }, "node_modules/express/node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", + "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", "dev": true, "license": "MIT" }, - "node_modules/express/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -7029,14 +6975,14 @@ } }, "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", "dev": true, "license": "MIT", "dependencies": { "debug": "2.6.9", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -11083,11 +11029,14 @@ } }, "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", "dev": true, - "license": "MIT" + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/merge-stream": { "version": "2.0.0", @@ -11107,9 +11056,9 @@ } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "license": "MIT", "dependencies": { @@ -11757,9 +11706,9 @@ } }, "node_modules/nise/node_modules/path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.9.0.tgz", + "integrity": "sha512-xIp7/apCFJuUHdDLWe8O1HIkb0kQrOMb/0u6FXQjemHn/ii5LrIzU6bdECnsiTF/GjZkMEKg1xdiZwNqDYlZ6g==", "dev": true, "license": "MIT", "dependencies": { @@ -13398,9 +13347,9 @@ "license": "MIT" }, "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", "dev": true, "license": "MIT", "dependencies": { @@ -13439,6 +13388,16 @@ "dev": true, "license": "MIT" }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/send/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -13457,16 +13416,16 @@ } }, "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", "dev": true, "license": "MIT", "dependencies": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.18.0" + "send": "0.19.0" }, "engines": { "node": ">= 0.8.0" @@ -14708,13 +14667,12 @@ } }, "node_modules/webpack": { - "version": "5.92.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.92.0.tgz", - "integrity": "sha512-Bsw2X39MYIgxouNATyVpCNVWBCuUwDgWtN78g6lSdPJRLaQ/PUVm/oXcaRAyY/sMFoKFQrsPeqvTizWtq7QPCA==", + "version": "5.95.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz", + "integrity": "sha512-2t3XstrKULz41MNMBF+cJ97TyHdyQ8HCt//pqErqDvNjU9YQBnZxIHa11VXsi7F3mb5/aO2tuDxdeTPdU7xu9Q==", "dev": true, "license": "MIT", "dependencies": { - "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.5", "@webassemblyjs/ast": "^1.12.1", "@webassemblyjs/wasm-edit": "^1.12.1", @@ -14723,7 +14681,7 @@ "acorn-import-attributes": "^1.9.5", "browserslist": "^4.21.10", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.17.0", + "enhanced-resolve": "^5.17.1", "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", diff --git a/package.json b/package.json index 4125e846..29230f6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.18.1", + "version": "1.18.2", "description": "The Content Management API is used to manage the content of your Contentstack account", "main": "./dist/node/contentstack-management.js", "browser": "./dist/web/contentstack-management.js", diff --git a/test/sanity-check/api/ungroupedVariants-test.js b/test/sanity-check/api/ungroupedVariants-test.js index 08169dc7..38eb19f4 100644 --- a/test/sanity-check/api/ungroupedVariants-test.js +++ b/test/sanity-check/api/ungroupedVariants-test.js @@ -23,14 +23,13 @@ describe('Ungrouped Variants api Test', () => { stack = jsonReader('stack.json') client = contentstackClient(user.authtoken) }) - it('Should create ungrouped variants create', done => { makeVariants() .create(variants) .then((variantsResponse) => { - // variantsUID = variantsResponse.uid - // expect(variantsResponse.uid).to.be.not.equal(null) - // expect(variantsResponse.name).to.be.equal(variants.name) + variantsUID = variantsResponse.uid + expect(variantsResponse.uid).to.be.not.equal(null) + expect(variantsResponse.name).to.be.equal(variants.name) done() }) .catch(done) @@ -55,8 +54,7 @@ describe('Ungrouped Variants api Test', () => { makeVariants(variantsUID) .fetch() .then((variantsResponse) => { - // expect(variantsResponse.uid).to.be.equal(variantsUID) - // expect(variantsResponse.name).to.be.equal(variants.name) + expect(variantsResponse.name).to.be.equal(variants.name) done() }) .catch(done) diff --git a/test/sanity-check/api/variantGroup-test.js b/test/sanity-check/api/variantGroup-test.js index 938d38b9..c1f1f080 100644 --- a/test/sanity-check/api/variantGroup-test.js +++ b/test/sanity-check/api/variantGroup-test.js @@ -19,8 +19,8 @@ describe('Variant Group api Test', () => { makeVariantGroup() .create(createVariantGroup) .then((variantGroup) => { - // expect(variantGroup.name).to.be.equal(createVariantGroup.name) - // expect(variantGroup).to.be.defined() + expect(variantGroup.name).to.be.equal(createVariantGroup.name) + expect(variantGroup.uid).to.be.equal(createVariantGroup.uid) done() }) .catch(done) diff --git a/test/sanity-check/api/variants-test.js b/test/sanity-check/api/variants-test.js index 55aec451..6f73976a 100644 --- a/test/sanity-check/api/variants-test.js +++ b/test/sanity-check/api/variants-test.js @@ -22,14 +22,14 @@ describe('Variants api Test', () => { makeVariantGroup() .create(createVariantGroup) .then((variantGroup) => { - // expect(variantGroup.name).to.be.equal(createVariantGroup.name) - // expect(variantGroup).to.be.defined() + expect(variantGroup.name).to.be.equal(createVariantGroup.name) + expect(variantGroup.uid).to.be.equal(createVariantGroup.uid) done() }) .catch(done) }) - it('Query to get a Variant Group from name', done => { + it('Query to get a Variant from name', done => { makeVariantGroup() .query({ name: createVariantGroup.name }) .find() @@ -49,8 +49,8 @@ describe('Variants api Test', () => { makeVariants() .create(variant) .then((variants) => { - // expect(variants.name).to.be.equal(variant.name) - // expect(variants.uid).to.be.not.equal(null) + expect(variants.name).to.be.equal(variant.name) + expect(variants.uid).to.be.not.equal(null) done() }) .catch(done) @@ -73,11 +73,11 @@ describe('Variants api Test', () => { }) it('Get a Variants from uid', done => { - makeVariantGroup('iphone_color_white').variants(variantUid) + makeVariants(variantUid) .fetch() .then((variants) => { - // expect(variants.name).to.be.equal(variant.name) - // expect(variants.uid).to.be.not.equal(null) + expect(variants.name).to.be.equal(variant.name) + expect(variants.uid).to.be.not.equal(null) done() }) .catch(done) @@ -130,7 +130,7 @@ describe('Variants api Test', () => { }) function makeVariants(uid = null) { - return client.stack({ api_key: process.env.API_KEY }).variantGroup('iphone_color_white').variants(uid) + return client.stack({ api_key: process.env.API_KEY }).variantGroup(variantGroupUid).variants(uid) } function makeVariantGroup(uid = null) {