@qrvey/utils 1.3.0-6 → 1.3.0-9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/cjs/column_format/helpers/columnTypeByChart.d.ts +1 -1
  2. package/dist/cjs/column_format/helpers/defineXYChartFormat.js +1 -1
  3. package/dist/cjs/dates/adapters/index.d.ts +11 -0
  4. package/dist/cjs/dates/adapters/index.js +27 -0
  5. package/dist/cjs/dates/index.d.ts +1 -0
  6. package/dist/cjs/dates/index.js +1 -0
  7. package/dist/cjs/filters/helpers/common/getFiltersByDatasetsColumns.d.ts +10 -0
  8. package/dist/cjs/filters/helpers/common/getFiltersByDatasetsColumns.js +27 -0
  9. package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
  10. package/dist/cjs/filters/helpers/common/index.js +1 -0
  11. package/dist/column_format/helpers/defineXYChartFormat.js +1 -1
  12. package/dist/dates/adapters/index.d.ts +11 -0
  13. package/dist/dates/adapters/index.js +11 -0
  14. package/dist/dates/index.d.ts +1 -0
  15. package/dist/dates/index.js +1 -0
  16. package/dist/filters/helpers/common/getFiltersByDatasetsColumns.d.ts +10 -0
  17. package/dist/filters/helpers/common/getFiltersByDatasetsColumns.js +23 -0
  18. package/dist/filters/helpers/common/index.d.ts +1 -0
  19. package/dist/filters/helpers/common/index.js +1 -0
  20. package/jest.config.js +1 -1
  21. package/package.json +5 -4
  22. package/src/column_format/helpers/defineXYChartFormat.ts +1 -3
  23. package/src/dates/adapters/index.ts +11 -0
  24. package/src/dates/index.ts +1 -0
  25. package/src/filters/helpers/common/getFiltersByDatasetsColumns.ts +35 -0
  26. package/src/filters/helpers/common/index.ts +1 -0
  27. package/test/tokens/isTokenLabel.test.js +259 -0
  28. package/tsconfig.json +1 -4
  29. package/test/tokens/isTokenLabel.test.ts +0 -129
@@ -13,4 +13,4 @@ import { IChartShelfType } from "../interfaces/IChartShelfType";
13
13
  * grouped.
14
14
  * @returns The column type of the column.
15
15
  */
16
- export declare const columnTypeByChart: (column: IChartColumn, shelfType: IChartShelfType, chartGroup: IChartGroupType, isGroupedTable?: boolean) => "DATE" | "NUMERIC" | "TEXT_LABEL" | import("../..").COMPLEX_COLUMN | import("../..").COMPOUND_COLUMN | NUMERICAL_COLUMN | COLUMN.SINGLE_CHOICE | COLUMN.MULTIPLE_CHOICE | COLUMN.YES_NO | COLUMN.RANKING | COLUMN.DATE | COLUMN.SIGNATURE | COLUMN.DROPDOWN | COLUMN.IMAGE | COLUMN.EMAIL_FORM | COLUMN.PHONE | COLUMN.PASSWORD | COLUMN.CHECKLIST | COLUMN.NPS_SCORE | COLUMN.NPS_FEEDBACK | COLUMN.TEXT_LABEL | COLUMN.TEXT_CATEGORY | COLUMN.LOOKUP | COLUMN.HEADLINE | COLUMN.SECTION | COLUMN.AGGREGATED_FORMULA | COLUMN.BUCKET | COLUMN.SLIDEBAR | COLUMN.NUMERIC | COLUMN.NUMERICC | COLUMN.NUMERICP | COLUMN.NUMERICG | COLUMN.RATING | COLUMN.TEXTFIELD | COLUMN.LONGTEXT | COLUMN.IMAGEUPLOAD | COLUMN.FILEUPLOAD | COLUMN.EXPRESSION | COLUMN.NAME | COLUMN.USADDRESS | COLUMN.ADDRESS;
16
+ export declare const columnTypeByChart: (column: IChartColumn, shelfType: IChartShelfType, chartGroup: IChartGroupType, isGroupedTable?: boolean) => import("../..").COMPLEX_COLUMN | import("../..").COMPOUND_COLUMN | NUMERICAL_COLUMN | COLUMN.SINGLE_CHOICE | COLUMN.MULTIPLE_CHOICE | COLUMN.YES_NO | COLUMN.RANKING | COLUMN.DATE | COLUMN.SIGNATURE | COLUMN.DROPDOWN | COLUMN.IMAGE | COLUMN.EMAIL_FORM | COLUMN.PHONE | COLUMN.PASSWORD | COLUMN.CHECKLIST | COLUMN.NPS_SCORE | COLUMN.NPS_FEEDBACK | COLUMN.TEXT_LABEL | COLUMN.TEXT_CATEGORY | COLUMN.LOOKUP | COLUMN.HEADLINE | COLUMN.SECTION | COLUMN.AGGREGATED_FORMULA | COLUMN.BUCKET | COLUMN.SLIDEBAR | COLUMN.NUMERIC | COLUMN.NUMERICC | COLUMN.NUMERICP | COLUMN.NUMERICG | COLUMN.RATING | COLUMN.TEXTFIELD | COLUMN.LONGTEXT | COLUMN.IMAGEUPLOAD | COLUMN.FILEUPLOAD | COLUMN.EXPRESSION | COLUMN.NAME | COLUMN.USADDRESS | COLUMN.ADDRESS | "DATE" | "NUMERIC" | "TEXT_LABEL";
@@ -23,7 +23,7 @@ const defineXYChartFormat = (column, settings) => {
23
23
  const columnType = (0, columnTypeByChart_1.columnTypeByChart)(column, shelfType, CHART_GROUP_1.CHART_GROUPS.XY);
24
24
  const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT_1.DATEGROUP_UNSUPPORT_FORMAT.some(gp => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
25
25
  const isUsedAsNumericColumn = type !== columnType;
26
- const hasDefaultFormat = ((0, __1.isEmpty)(selectedFormat) && (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText) || ((selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText);
26
+ const hasDefaultFormat = (0, __1.isEmpty)(selectedFormat) || ((outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText) || ((selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText);
27
27
  switch (columnType) {
28
28
  case __1.COLUMN.YES_NO:
29
29
  case __1.COLUMN.PHONE:
@@ -0,0 +1,11 @@
1
+ export * from './dateToHms';
2
+ export * from './dateToMdyDate';
3
+ export * from './dateToMonthYear';
4
+ export * from './dateToQuarterYear';
5
+ export * from './dateToWeekYear';
6
+ export * from './dateToYear';
7
+ export * from './mdyDateToDate';
8
+ export * from './monthYearToDate';
9
+ export * from './quarterYearToDate';
10
+ export * from './weekYearToDate';
11
+ export * from './yearToDate';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./dateToHms"), exports);
18
+ __exportStar(require("./dateToMdyDate"), exports);
19
+ __exportStar(require("./dateToMonthYear"), exports);
20
+ __exportStar(require("./dateToQuarterYear"), exports);
21
+ __exportStar(require("./dateToWeekYear"), exports);
22
+ __exportStar(require("./dateToYear"), exports);
23
+ __exportStar(require("./mdyDateToDate"), exports);
24
+ __exportStar(require("./monthYearToDate"), exports);
25
+ __exportStar(require("./quarterYearToDate"), exports);
26
+ __exportStar(require("./weekYearToDate"), exports);
27
+ __exportStar(require("./yearToDate"), exports);
@@ -3,3 +3,4 @@ export * from './helpers/index';
3
3
  export * from './interfaces/index';
4
4
  export * from './range/index';
5
5
  export * from './relative/index';
6
+ export * from './adapters/index';
@@ -19,3 +19,4 @@ __exportStar(require("./helpers/index"), exports);
19
19
  __exportStar(require("./interfaces/index"), exports);
20
20
  __exportStar(require("./range/index"), exports);
21
21
  __exportStar(require("./relative/index"), exports);
22
+ __exportStar(require("./adapters/index"), exports);
@@ -0,0 +1,10 @@
1
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
2
+ import { IFUData } from "../../interfaces/ui/IFUData";
3
+ /**
4
+ * Filtering the filters by the columns of datasets.
5
+ * Module specially for CLS.
6
+ * @param data the filter data
7
+ * @param datasets the collection of datasets and their columns
8
+ * @returns A new filter data with the filtered filters by columns
9
+ */
10
+ export declare function getFiltersByDatasetsColumns(data: IFUData, datasets?: IDataset[]): IFUData;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFiltersByDatasetsColumns = void 0;
4
+ const isEmpty_1 = require("../../../general/mix/isEmpty");
5
+ /**
6
+ * Filtering the filters by the columns of datasets.
7
+ * Module specially for CLS.
8
+ * @param data the filter data
9
+ * @param datasets the collection of datasets and their columns
10
+ * @returns A new filter data with the filtered filters by columns
11
+ */
12
+ function getFiltersByDatasetsColumns(data, datasets = []) {
13
+ if ((0, isEmpty_1.isEmpty)(data) || (0, isEmpty_1.isEmpty)(data.scopes))
14
+ return;
15
+ return Object.assign(Object.assign({}, data), { scopes: data.scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(filterDataset => {
16
+ const dataset = datasets.find(data => data.qrveyid === filterDataset.qrveyid);
17
+ if (!(0, isEmpty_1.isEmpty)(dataset)) {
18
+ return Object.assign(Object.assign({}, filterDataset), { filters: filterDataset.filters.map(filter => {
19
+ const column = (dataset.options || []).find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid);
20
+ if (!(0, isEmpty_1.isEmpty)(column)) {
21
+ return Object.assign({}, filter);
22
+ }
23
+ }).filter(Boolean) });
24
+ }
25
+ }).filter(dataset => !(0, isEmpty_1.isEmpty)(dataset) && dataset.filters.length > 0) }))).filter(scope => !(0, isEmpty_1.isEmpty)(scope) && scope.datasets.length > 0) });
26
+ }
27
+ exports.getFiltersByDatasetsColumns = getFiltersByDatasetsColumns;
@@ -7,6 +7,7 @@ export * from './getFilterColumnLabel';
7
7
  export * from './getFilterid';
8
8
  export * from './getFilterLabel';
9
9
  export * from './getFiltersByAggregateColumn';
10
+ export * from './getFiltersByDatasetsColumns';
10
11
  export * from './getFiltersByParams';
11
12
  export * from './getFiltersByScopes';
12
13
  export * from './getFiltersByScopesIds';
@@ -23,6 +23,7 @@ __exportStar(require("./getFilterColumnLabel"), exports);
23
23
  __exportStar(require("./getFilterid"), exports);
24
24
  __exportStar(require("./getFilterLabel"), exports);
25
25
  __exportStar(require("./getFiltersByAggregateColumn"), exports);
26
+ __exportStar(require("./getFiltersByDatasetsColumns"), exports);
26
27
  __exportStar(require("./getFiltersByParams"), exports);
27
28
  __exportStar(require("./getFiltersByScopes"), exports);
28
29
  __exportStar(require("./getFiltersByScopesIds"), exports);
@@ -20,7 +20,7 @@ export const defineXYChartFormat = (column, settings) => {
20
20
  const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.XY);
21
21
  const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some(gp => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
22
22
  const isUsedAsNumericColumn = type !== columnType;
23
- const hasDefaultFormat = (isEmpty(selectedFormat) && (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText) || ((selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText);
23
+ const hasDefaultFormat = isEmpty(selectedFormat) || ((outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText) || ((selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText);
24
24
  switch (columnType) {
25
25
  case COLUMN.YES_NO:
26
26
  case COLUMN.PHONE:
@@ -0,0 +1,11 @@
1
+ export * from './dateToHms';
2
+ export * from './dateToMdyDate';
3
+ export * from './dateToMonthYear';
4
+ export * from './dateToQuarterYear';
5
+ export * from './dateToWeekYear';
6
+ export * from './dateToYear';
7
+ export * from './mdyDateToDate';
8
+ export * from './monthYearToDate';
9
+ export * from './quarterYearToDate';
10
+ export * from './weekYearToDate';
11
+ export * from './yearToDate';
@@ -0,0 +1,11 @@
1
+ export * from './dateToHms';
2
+ export * from './dateToMdyDate';
3
+ export * from './dateToMonthYear';
4
+ export * from './dateToQuarterYear';
5
+ export * from './dateToWeekYear';
6
+ export * from './dateToYear';
7
+ export * from './mdyDateToDate';
8
+ export * from './monthYearToDate';
9
+ export * from './quarterYearToDate';
10
+ export * from './weekYearToDate';
11
+ export * from './yearToDate';
@@ -3,3 +3,4 @@ export * from './helpers/index';
3
3
  export * from './interfaces/index';
4
4
  export * from './range/index';
5
5
  export * from './relative/index';
6
+ export * from './adapters/index';
@@ -3,3 +3,4 @@ export * from './helpers/index';
3
3
  export * from './interfaces/index';
4
4
  export * from './range/index';
5
5
  export * from './relative/index';
6
+ export * from './adapters/index';
@@ -0,0 +1,10 @@
1
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
2
+ import { IFUData } from "../../interfaces/ui/IFUData";
3
+ /**
4
+ * Filtering the filters by the columns of datasets.
5
+ * Module specially for CLS.
6
+ * @param data the filter data
7
+ * @param datasets the collection of datasets and their columns
8
+ * @returns A new filter data with the filtered filters by columns
9
+ */
10
+ export declare function getFiltersByDatasetsColumns(data: IFUData, datasets?: IDataset[]): IFUData;
@@ -0,0 +1,23 @@
1
+ import { isEmpty } from "../../../general/mix/isEmpty";
2
+ /**
3
+ * Filtering the filters by the columns of datasets.
4
+ * Module specially for CLS.
5
+ * @param data the filter data
6
+ * @param datasets the collection of datasets and their columns
7
+ * @returns A new filter data with the filtered filters by columns
8
+ */
9
+ export function getFiltersByDatasetsColumns(data, datasets = []) {
10
+ if (isEmpty(data) || isEmpty(data.scopes))
11
+ return;
12
+ return Object.assign(Object.assign({}, data), { scopes: data.scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(filterDataset => {
13
+ const dataset = datasets.find(data => data.qrveyid === filterDataset.qrveyid);
14
+ if (!isEmpty(dataset)) {
15
+ return Object.assign(Object.assign({}, filterDataset), { filters: filterDataset.filters.map(filter => {
16
+ const column = (dataset.options || []).find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid);
17
+ if (!isEmpty(column)) {
18
+ return Object.assign({}, filter);
19
+ }
20
+ }).filter(Boolean) });
21
+ }
22
+ }).filter(dataset => !isEmpty(dataset) && dataset.filters.length > 0) }))).filter(scope => !isEmpty(scope) && scope.datasets.length > 0) });
23
+ }
@@ -7,6 +7,7 @@ export * from './getFilterColumnLabel';
7
7
  export * from './getFilterid';
8
8
  export * from './getFilterLabel';
9
9
  export * from './getFiltersByAggregateColumn';
10
+ export * from './getFiltersByDatasetsColumns';
10
11
  export * from './getFiltersByParams';
11
12
  export * from './getFiltersByScopes';
12
13
  export * from './getFiltersByScopesIds';
@@ -7,6 +7,7 @@ export * from './getFilterColumnLabel';
7
7
  export * from './getFilterid';
8
8
  export * from './getFilterLabel';
9
9
  export * from './getFiltersByAggregateColumn';
10
+ export * from './getFiltersByDatasetsColumns';
10
11
  export * from './getFiltersByParams';
11
12
  export * from './getFiltersByScopes';
12
13
  export * from './getFiltersByScopesIds';
package/jest.config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- preset: 'ts-jest',
2
+ // preset: 'ts-jest',
3
3
  testEnvironment: 'node',
4
4
  verbose: true,
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.3.0-6",
3
+ "version": "1.3.0-9",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
@@ -11,6 +11,7 @@
11
11
  "compodoc:server": "./node_modules/.bin/compodoc -p ./tsconfig.doc.json -s --port=4400",
12
12
  "lint": "eslint src --quiet --exit-on-fatal-error --ext .ts,.js",
13
13
  "lint-dev": "eslint src --debug --ext .ts,.tsx",
14
+ "pipeline": "npm run build-clean && npm run lint && npm run test",
14
15
  "publishing-old": "node ./scripts/prepare-publish && np",
15
16
  "publishing-prerelease-old": "node ./scripts/prepare-publish && np --any-branch --tag=$npm_config_tag",
16
17
  "publishing-beta-1": "node ./scripts/publishing --np-new-version=$npm_config_np_new_version --np-any-branch=$npm_config_np_any_branch --np-tag=$npm_config_np_tag",
@@ -22,13 +23,13 @@
22
23
  "license": "MIT",
23
24
  "devDependencies": {
24
25
  "@compodoc/compodoc": "1.1.19",
25
- "@types/jest": "27.5.0",
26
+ "@types/jest": "27.5.1",
26
27
  "@typescript-eslint/eslint-plugin": "5.22.0",
27
28
  "@typescript-eslint/parser": "5.22.0",
28
29
  "eslint": "8.14.0",
29
- "jest": "27.5.1",
30
+ "jest": "28.1.0",
30
31
  "np": "7.6.1",
31
- "ts-jest": "27.1.4",
32
+ "ts-jest": "28.0.2",
32
33
  "typedoc": "0.22.15",
33
34
  "typescript": "4.6.4"
34
35
  },
@@ -27,9 +27,7 @@ export const defineXYChartFormat = (column: IChartColumn, settings: IColumnForma
27
27
 
28
28
  const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some(gp => gp === dateGroup?.label);
29
29
  const isUsedAsNumericColumn = type !== columnType;
30
-
31
-
32
- const hasDefaultFormat = (isEmpty(selectedFormat) && outputFormat?.format === defaultText) || (selectedFormat?.format === defaultText);
30
+ const hasDefaultFormat = isEmpty(selectedFormat) || (outputFormat?.format === defaultText) || (selectedFormat?.format === defaultText);
33
31
 
34
32
 
35
33
  switch(columnType) {
@@ -0,0 +1,11 @@
1
+ export * from './dateToHms';
2
+ export * from './dateToMdyDate';
3
+ export * from './dateToMonthYear';
4
+ export * from './dateToQuarterYear';
5
+ export * from './dateToWeekYear';
6
+ export * from './dateToYear';
7
+ export * from './mdyDateToDate';
8
+ export * from './monthYearToDate';
9
+ export * from './quarterYearToDate';
10
+ export * from './weekYearToDate';
11
+ export * from './yearToDate';
@@ -3,3 +3,4 @@ export * from './helpers/index';
3
3
  export * from './interfaces/index';
4
4
  export * from './range/index';
5
5
  export * from './relative/index';
6
+ export * from './adapters/index';
@@ -0,0 +1,35 @@
1
+ import { isEmpty } from "../../../general/mix/isEmpty";
2
+ import { IDataset } from "../../../qrvey/interfaces/IDataset";
3
+ import { IFUData } from "../../interfaces/ui/IFUData";
4
+
5
+ /**
6
+ * Filtering the filters by the columns of datasets.
7
+ * Module specially for CLS.
8
+ * @param data the filter data
9
+ * @param datasets the collection of datasets and their columns
10
+ * @returns A new filter data with the filtered filters by columns
11
+ */
12
+ export function getFiltersByDatasetsColumns(data: IFUData, datasets: IDataset[] = []): IFUData {
13
+ if (isEmpty(data) || isEmpty(data.scopes)) return;
14
+
15
+ return {
16
+ ...data,
17
+ scopes: data.scopes.map(scope => ({
18
+ ...scope,
19
+ datasets: scope.datasets.map(filterDataset => {
20
+ const dataset = datasets.find(data => data.qrveyid === filterDataset.qrveyid);
21
+ if (!isEmpty(dataset)) {
22
+ return {
23
+ ...filterDataset,
24
+ filters: filterDataset.filters.map(filter => {
25
+ const column = (dataset.options || []).find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid);
26
+ if (!isEmpty(column)) {
27
+ return { ...filter };
28
+ }
29
+ }).filter(Boolean)
30
+ };
31
+ }
32
+ }).filter(dataset => !isEmpty(dataset) && dataset.filters.length > 0)
33
+ })).filter(scope => !isEmpty(scope) && scope.datasets.length > 0)
34
+ };
35
+ }
@@ -7,6 +7,7 @@ export * from './getFilterColumnLabel';
7
7
  export * from './getFilterid';
8
8
  export * from './getFilterLabel';
9
9
  export * from './getFiltersByAggregateColumn';
10
+ export * from './getFiltersByDatasetsColumns';
10
11
  export * from './getFiltersByParams';
11
12
  export * from './getFiltersByScopes';
12
13
  export * from './getFiltersByScopesIds';
@@ -0,0 +1,259 @@
1
+ // import { isTokenLabel } from '../../src/tokens/isTokenLabel';
2
+
3
+ // describe('Testing undefined argument', function () {
4
+ // test('no argument passed', function () {
5
+ // const validation: boolean = isTokenLabel();
6
+ // expect(validation).toBeFalsy();
7
+ // });
8
+
9
+ // test('Undefined argument', function () {
10
+ // const validation: boolean = isTokenLabel(undefined);
11
+ // expect(validation).toBeFalsy();
12
+ // });
13
+
14
+ // test('Null argument', function () {
15
+ // const validation: boolean = isTokenLabel(null);
16
+ // expect(validation).toBeFalsy();
17
+ // });
18
+ // });
19
+
20
+ // describe('Testing no-string arguments', function () {
21
+ // const variable1: any = 1;
22
+ // const variable2: any = false;
23
+ // const variable3: any = new Date();
24
+ // const variable4: any = { const1: 'Hello', const2: 'World'};
25
+ // const variable5: any = ['Hello', 'World'];
26
+
27
+ // test('Numeric variable', function () {
28
+ // const validation: boolean = isTokenLabel(variable1);
29
+ // expect(validation).toBeFalsy();
30
+ // });
31
+
32
+ // test('Boolean variable', function () {
33
+ // const validation: boolean = isTokenLabel(variable2);
34
+ // expect(validation).toBeFalsy();
35
+ // });
36
+
37
+ // test('Date object variable', function () {
38
+ // const validation: boolean = isTokenLabel(variable3);
39
+ // expect(validation).toBeFalsy();
40
+ // });
41
+
42
+ // test('Object variable', function () {
43
+ // const validation: boolean = isTokenLabel(variable4);
44
+ // expect(validation).toBeFalsy();
45
+ // });
46
+
47
+ // test('Array variable', function () {
48
+ // const validation: boolean = isTokenLabel(variable5);
49
+ // expect(validation).toBeFalsy();
50
+ // });
51
+ // });
52
+
53
+ // describe('Testing invalid string argument', function () {
54
+ // const variable1: string = '';
55
+ // const variable2: string = 'Hello World';
56
+ // const variable3: string = '{}';
57
+ // const variable4: string = '{{}}';
58
+ // const variable5: string = '{{ }}';
59
+ // const variable6: string = '{{ Hello }}';
60
+ // const variable7: string = '{{Hello}';
61
+ // const variable8: string = '{{Hello}}{{World}}';
62
+ // const variable9: string = '{Hello}';
63
+
64
+ // test('Empty string', function () {
65
+ // const validation: boolean = isTokenLabel(variable1);
66
+ // expect(validation).toBeFalsy();
67
+ // });
68
+
69
+ // test('Non-empty and regular string', function () {
70
+ // const validation: boolean = isTokenLabel(variable2);
71
+ // expect(validation).toBeFalsy();
72
+ // });
73
+
74
+ // test('Single curly brackets and empty label', function () {
75
+ // const validation: boolean = isTokenLabel(variable3);
76
+ // expect(validation).toBeFalsy();
77
+ // });
78
+
79
+ // test('Double curly brackets and empty label', function () {
80
+ // const validation: boolean = isTokenLabel(variable4);
81
+ // expect(validation).toBeFalsy();
82
+ // });
83
+
84
+ // test('Double curly brackets and space between them', function () {
85
+ // const validation: boolean = isTokenLabel(variable5);
86
+ // expect(validation).toBeFalsy();
87
+ // });
88
+
89
+ // test('Double curly brackets and non-empty label with space between them', function () {
90
+ // const validation: boolean = isTokenLabel(variable6);
91
+ // expect(validation).toBeFalsy();
92
+ // });
93
+
94
+ // test('Double left and single right curly brackets and non-empty label', function () {
95
+ // const validation: boolean = isTokenLabel(variable7);
96
+ // expect(validation).toBeFalsy();
97
+ // });
98
+
99
+ // test('Two data tokens in a single string', function () {
100
+ // const validation: boolean = isTokenLabel(variable8);
101
+ // expect(validation).toBeFalsy();
102
+ // });
103
+
104
+ // test('Single curly brackets and non-empty label', function () {
105
+ // const validation: boolean = isTokenLabel(variable9);
106
+ // expect(validation).toBeFalsy();
107
+ // });
108
+ // });
109
+
110
+ // describe('Regular scenarios', function () {
111
+ // const variable1: string = '{{NOW}}';
112
+ // const variable2: string = '{{LAST_YEAR_END}}';
113
+ // const variable3: string = '{{data.marathonparatooltips-cambiodesorting.FECHA.avg}}';
114
+
115
+ // test('Scenario #1', function () {
116
+ // const validation: boolean = isTokenLabel(variable1);
117
+ // expect(validation).toBeTruthy();
118
+ // });
119
+
120
+ // test('Scenario #2', function () {
121
+ // const validation: boolean = isTokenLabel(variable2);
122
+ // expect(validation).toBeTruthy();
123
+ // });
124
+
125
+ // test('Scenario #3', function () {
126
+ // const validation: boolean = isTokenLabel(variable3);
127
+ // expect(validation).toBeTruthy();
128
+ // });
129
+ // });
130
+
131
+ const { isTokenLabel } = require("../../dist/cjs");
132
+
133
+ describe('Testing undefined argument', function () {
134
+ test('no argument passed', function () {
135
+ const validation = isTokenLabel();
136
+ expect(validation).toBeFalsy();
137
+ });
138
+
139
+ test('Undefined argument', function () {
140
+ const validation = isTokenLabel(undefined);
141
+ expect(validation).toBeFalsy();
142
+ });
143
+
144
+ test('Null argument', function () {
145
+ const validation = isTokenLabel(null);
146
+ expect(validation).toBeFalsy();
147
+ });
148
+ });
149
+
150
+ describe('Testing no-string arguments', function () {
151
+ const variable1 = 1;
152
+ const variable2 = false;
153
+ const variable3 = new Date();
154
+ const variable4 = { const1: 'Hello', const2: 'World'};
155
+ const variable5 = ['Hello', 'World'];
156
+
157
+ test('Numeric variable', function () {
158
+ const validation = isTokenLabel(variable1);
159
+ expect(validation).toBeFalsy();
160
+ });
161
+
162
+ test('Boolean variable', function () {
163
+ const validation = isTokenLabel(variable2);
164
+ expect(validation).toBeFalsy();
165
+ });
166
+
167
+ test('Date object variable', function () {
168
+ const validation = isTokenLabel(variable3);
169
+ expect(validation).toBeFalsy();
170
+ });
171
+
172
+ test('Object variable', function () {
173
+ const validation = isTokenLabel(variable4);
174
+ expect(validation).toBeFalsy();
175
+ });
176
+
177
+ test('Array variable', function () {
178
+ const validation = isTokenLabel(variable5);
179
+ expect(validation).toBeFalsy();
180
+ });
181
+ });
182
+
183
+ describe('Testing invalid string argument', function () {
184
+ const variable1 = '';
185
+ const variable2 = 'Hello World';
186
+ const variable3 = '{}';
187
+ const variable4 = '{{}}';
188
+ const variable5 = '{{ }}';
189
+ const variable6 = '{{ Hello }}';
190
+ const variable7 = '{{Hello}';
191
+ const variable8 = '{{Hello}}{{World}}';
192
+ const variable9 = '{Hello}';
193
+
194
+ test('Empty string', function () {
195
+ const validation = isTokenLabel(variable1);
196
+ expect(validation).toBeFalsy();
197
+ });
198
+
199
+ test('Non-empty and regular string', function () {
200
+ const validation = isTokenLabel(variable2);
201
+ expect(validation).toBeFalsy();
202
+ });
203
+
204
+ test('Single curly brackets and empty label', function () {
205
+ const validation = isTokenLabel(variable3);
206
+ expect(validation).toBeFalsy();
207
+ });
208
+
209
+ test('Double curly brackets and empty label', function () {
210
+ const validation = isTokenLabel(variable4);
211
+ expect(validation).toBeFalsy();
212
+ });
213
+
214
+ test('Double curly brackets and space between them', function () {
215
+ const validation = isTokenLabel(variable5);
216
+ expect(validation).toBeFalsy();
217
+ });
218
+
219
+ test('Double curly brackets and non-empty label with space between them', function () {
220
+ const validation = isTokenLabel(variable6);
221
+ expect(validation).toBeFalsy();
222
+ });
223
+
224
+ test('Double left and single right curly brackets and non-empty label', function () {
225
+ const validation = isTokenLabel(variable7);
226
+ expect(validation).toBeFalsy();
227
+ });
228
+
229
+ test('Two data tokens in a single string', function () {
230
+ const validation = isTokenLabel(variable8);
231
+ expect(validation).toBeFalsy();
232
+ });
233
+
234
+ test('Single curly brackets and non-empty label', function () {
235
+ const validation = isTokenLabel(variable9);
236
+ expect(validation).toBeFalsy();
237
+ });
238
+ });
239
+
240
+ describe('Regular scenarios', function () {
241
+ const variable1 = '{{NOW}}';
242
+ const variable2 = '{{LAST_YEAR_END}}';
243
+ const variable3 = '{{data.marathonparatooltips-cambiodesorting.FECHA.avg}}';
244
+
245
+ test('Scenario #1', function () {
246
+ const validation = isTokenLabel(variable1);
247
+ expect(validation).toBeTruthy();
248
+ });
249
+
250
+ test('Scenario #2', function () {
251
+ const validation = isTokenLabel(variable2);
252
+ expect(validation).toBeTruthy();
253
+ });
254
+
255
+ test('Scenario #3', function () {
256
+ const validation = isTokenLabel(variable3);
257
+ expect(validation).toBeTruthy();
258
+ });
259
+ });
package/tsconfig.json CHANGED
@@ -62,8 +62,5 @@
62
62
 
63
63
  /* Advanced Options */
64
64
  "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
65
- },
66
- "exclude": [
67
- "test"
68
- ]
65
+ }
69
66
  }
@@ -1,129 +0,0 @@
1
- import { isTokenLabel } from '../../src/tokens/isTokenLabel';
2
-
3
- describe('Testing undefined argument', function () {
4
- test('no argument passed', function () {
5
- const validation: boolean = isTokenLabel();
6
- expect(validation).toBeFalsy();
7
- });
8
-
9
- test('Undefined argument', function () {
10
- const validation: boolean = isTokenLabel(undefined);
11
- expect(validation).toBeFalsy();
12
- });
13
-
14
- test('Null argument', function () {
15
- const validation: boolean = isTokenLabel(null);
16
- expect(validation).toBeFalsy();
17
- });
18
- });
19
-
20
- describe('Testing no-string arguments', function () {
21
- const variable1: any = 1;
22
- const variable2: any = false;
23
- const variable3: any = new Date();
24
- const variable4: any = { const1: 'Hello', const2: 'World'};
25
- const variable5: any = ['Hello', 'World'];
26
-
27
- test('Numeric variable', function () {
28
- const validation: boolean = isTokenLabel(variable1);
29
- expect(validation).toBeFalsy();
30
- });
31
-
32
- test('Boolean variable', function () {
33
- const validation: boolean = isTokenLabel(variable2);
34
- expect(validation).toBeFalsy();
35
- });
36
-
37
- test('Date object variable', function () {
38
- const validation: boolean = isTokenLabel(variable3);
39
- expect(validation).toBeFalsy();
40
- });
41
-
42
- test('Object variable', function () {
43
- const validation: boolean = isTokenLabel(variable4);
44
- expect(validation).toBeFalsy();
45
- });
46
-
47
- test('Array variable', function () {
48
- const validation: boolean = isTokenLabel(variable5);
49
- expect(validation).toBeFalsy();
50
- });
51
- });
52
-
53
- describe('Testing invalid string argument', function () {
54
- const variable1: string = '';
55
- const variable2: string = 'Hello World';
56
- const variable3: string = '{}';
57
- const variable4: string = '{{}}';
58
- const variable5: string = '{{ }}';
59
- const variable6: string = '{{ Hello }}';
60
- const variable7: string = '{{Hello}';
61
- const variable8: string = '{{Hello}}{{World}}';
62
- const variable9: string = '{Hello}';
63
-
64
- test('Empty string', function () {
65
- const validation: boolean = isTokenLabel(variable1);
66
- expect(validation).toBeFalsy();
67
- });
68
-
69
- test('Non-empty and regular string', function () {
70
- const validation: boolean = isTokenLabel(variable2);
71
- expect(validation).toBeFalsy();
72
- });
73
-
74
- test('Single curly brackets and empty label', function () {
75
- const validation: boolean = isTokenLabel(variable3);
76
- expect(validation).toBeFalsy();
77
- });
78
-
79
- test('Double curly brackets and empty label', function () {
80
- const validation: boolean = isTokenLabel(variable4);
81
- expect(validation).toBeFalsy();
82
- });
83
-
84
- test('Double curly brackets and space between them', function () {
85
- const validation: boolean = isTokenLabel(variable5);
86
- expect(validation).toBeFalsy();
87
- });
88
-
89
- test('Double curly brackets and non-empty label with space between them', function () {
90
- const validation: boolean = isTokenLabel(variable6);
91
- expect(validation).toBeFalsy();
92
- });
93
-
94
- test('Double left and single right curly brackets and non-empty label', function () {
95
- const validation: boolean = isTokenLabel(variable7);
96
- expect(validation).toBeFalsy();
97
- });
98
-
99
- test('Two data tokens in a single string', function () {
100
- const validation: boolean = isTokenLabel(variable8);
101
- expect(validation).toBeFalsy();
102
- });
103
-
104
- test('Single curly brackets and non-empty label', function () {
105
- const validation: boolean = isTokenLabel(variable9);
106
- expect(validation).toBeFalsy();
107
- });
108
- });
109
-
110
- describe('Regular scenarios', function () {
111
- const variable1: string = '{{NOW}}';
112
- const variable2: string = '{{LAST_YEAR_END}}';
113
- const variable3: string = '{{data.marathonparatooltips-cambiodesorting.FECHA.avg}}';
114
-
115
- test('Scenario #1', function () {
116
- const validation: boolean = isTokenLabel(variable1);
117
- expect(validation).toBeTruthy();
118
- });
119
-
120
- test('Scenario #2', function () {
121
- const validation: boolean = isTokenLabel(variable2);
122
- expect(validation).toBeTruthy();
123
- });
124
-
125
- test('Scenario #3', function () {
126
- const validation: boolean = isTokenLabel(variable3);
127
- expect(validation).toBeTruthy();
128
- });
129
- });