@qrvey/utils 1.3.0-5 → 1.3.0-6
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.
- package/bitbucket-pipelines.yml +1 -1
- package/dist/cjs/column_format/helpers/columnTypeByChart.d.ts +1 -1
- package/dist/cjs/general/array/addPropertyToArrayOfObjects.d.ts +22 -0
- package/dist/cjs/general/array/addPropertyToArrayOfObjects.js +32 -0
- package/dist/cjs/general/array/index.d.ts +1 -0
- package/dist/cjs/general/array/index.js +1 -0
- package/dist/general/array/addPropertyToArrayOfObjects.d.ts +22 -0
- package/dist/general/array/addPropertyToArrayOfObjects.js +28 -0
- package/dist/general/array/index.d.ts +1 -0
- package/dist/general/array/index.js +1 -0
- package/jest.config.js +1 -0
- package/package.json +7 -6
- package/src/general/array/addPropertyToArrayOfObjects.ts +32 -0
- package/src/general/array/index.ts +1 -0
- package/test/general/array/addPropertyToArrayOfObjects.test.js +96 -0
- package/test/tokens/{isTokenLabel.test.js → isTokenLabel.test.ts} +38 -38
- package/tsconfig.json +3 -0
package/bitbucket-pipelines.yml
CHANGED
|
@@ -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) => 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) => "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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* It takes an array of objects, adds a property to each object, and returns the new array.
|
|
3
|
+
* @param {Object} info - Information needed to add property to the array of objects.
|
|
4
|
+
* @param {Array} info.array - The array of objects you want to add a property to.
|
|
5
|
+
* @param {string} info.property - The property you want to add to the object.
|
|
6
|
+
* @param {any} info.value - - The value to be added to the array of objects.
|
|
7
|
+
* ----------------------------------------------------------------------------------------------
|
|
8
|
+
* @example <caption>Example usage of addPropertyToArrayOfObjects.</caption>
|
|
9
|
+
* addPropertyToArrayOfObjects({
|
|
10
|
+
* array: [{ name: "John", lastName: "Doe" }, { name: "Chris", lastName: "Musk" }],
|
|
11
|
+
* property: "lastName",
|
|
12
|
+
* value: 'Peck'
|
|
13
|
+
* });
|
|
14
|
+
* @returns the new array created.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addPropertyToArrayOfObjects(obj: AddPropertyToArrayOfObjectsParams): any[];
|
|
17
|
+
declare type AddPropertyToArrayOfObjectsParams = {
|
|
18
|
+
array: any[];
|
|
19
|
+
property: string;
|
|
20
|
+
value: any;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addPropertyToArrayOfObjects = void 0;
|
|
4
|
+
const isEmpty_1 = require("../mix/isEmpty");
|
|
5
|
+
const isObject_1 = require("../object/isObject");
|
|
6
|
+
/**
|
|
7
|
+
* It takes an array of objects, adds a property to each object, and returns the new array.
|
|
8
|
+
* @param {Object} info - Information needed to add property to the array of objects.
|
|
9
|
+
* @param {Array} info.array - The array of objects you want to add a property to.
|
|
10
|
+
* @param {string} info.property - The property you want to add to the object.
|
|
11
|
+
* @param {any} info.value - - The value to be added to the array of objects.
|
|
12
|
+
* ----------------------------------------------------------------------------------------------
|
|
13
|
+
* @example <caption>Example usage of addPropertyToArrayOfObjects.</caption>
|
|
14
|
+
* addPropertyToArrayOfObjects({
|
|
15
|
+
* array: [{ name: "John", lastName: "Doe" }, { name: "Chris", lastName: "Musk" }],
|
|
16
|
+
* property: "lastName",
|
|
17
|
+
* value: 'Peck'
|
|
18
|
+
* });
|
|
19
|
+
* @returns the new array created.
|
|
20
|
+
*/
|
|
21
|
+
function addPropertyToArrayOfObjects(obj) {
|
|
22
|
+
if ((0, isEmpty_1.isEmpty)(obj) || !(0, isObject_1.isObject)(obj))
|
|
23
|
+
return [];
|
|
24
|
+
const { array, property, value } = obj;
|
|
25
|
+
if (Array.isArray(array)) {
|
|
26
|
+
if ((0, isEmpty_1.isEmpty)(array) || (0, isEmpty_1.isEmpty)(property))
|
|
27
|
+
return array;
|
|
28
|
+
return array.map((element) => (Object.assign(Object.assign({}, element), { [property]: value })));
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
exports.addPropertyToArrayOfObjects = addPropertyToArrayOfObjects;
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./addPropertyToArrayOfObjects"), exports);
|
|
17
18
|
__exportStar(require("./delete"), exports);
|
|
18
19
|
__exportStar(require("./flattenDeep"), exports);
|
|
19
20
|
__exportStar(require("./filterNestedTree"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* It takes an array of objects, adds a property to each object, and returns the new array.
|
|
3
|
+
* @param {Object} info - Information needed to add property to the array of objects.
|
|
4
|
+
* @param {Array} info.array - The array of objects you want to add a property to.
|
|
5
|
+
* @param {string} info.property - The property you want to add to the object.
|
|
6
|
+
* @param {any} info.value - - The value to be added to the array of objects.
|
|
7
|
+
* ----------------------------------------------------------------------------------------------
|
|
8
|
+
* @example <caption>Example usage of addPropertyToArrayOfObjects.</caption>
|
|
9
|
+
* addPropertyToArrayOfObjects({
|
|
10
|
+
* array: [{ name: "John", lastName: "Doe" }, { name: "Chris", lastName: "Musk" }],
|
|
11
|
+
* property: "lastName",
|
|
12
|
+
* value: 'Peck'
|
|
13
|
+
* });
|
|
14
|
+
* @returns the new array created.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addPropertyToArrayOfObjects(obj: AddPropertyToArrayOfObjectsParams): any[];
|
|
17
|
+
declare type AddPropertyToArrayOfObjectsParams = {
|
|
18
|
+
array: any[];
|
|
19
|
+
property: string;
|
|
20
|
+
value: any;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isEmpty } from '../mix/isEmpty';
|
|
2
|
+
import { isObject } from '../object/isObject';
|
|
3
|
+
/**
|
|
4
|
+
* It takes an array of objects, adds a property to each object, and returns the new array.
|
|
5
|
+
* @param {Object} info - Information needed to add property to the array of objects.
|
|
6
|
+
* @param {Array} info.array - The array of objects you want to add a property to.
|
|
7
|
+
* @param {string} info.property - The property you want to add to the object.
|
|
8
|
+
* @param {any} info.value - - The value to be added to the array of objects.
|
|
9
|
+
* ----------------------------------------------------------------------------------------------
|
|
10
|
+
* @example <caption>Example usage of addPropertyToArrayOfObjects.</caption>
|
|
11
|
+
* addPropertyToArrayOfObjects({
|
|
12
|
+
* array: [{ name: "John", lastName: "Doe" }, { name: "Chris", lastName: "Musk" }],
|
|
13
|
+
* property: "lastName",
|
|
14
|
+
* value: 'Peck'
|
|
15
|
+
* });
|
|
16
|
+
* @returns the new array created.
|
|
17
|
+
*/
|
|
18
|
+
export function addPropertyToArrayOfObjects(obj) {
|
|
19
|
+
if (isEmpty(obj) || !isObject(obj))
|
|
20
|
+
return [];
|
|
21
|
+
const { array, property, value } = obj;
|
|
22
|
+
if (Array.isArray(array)) {
|
|
23
|
+
if (isEmpty(array) || isEmpty(property))
|
|
24
|
+
return array;
|
|
25
|
+
return array.map((element) => (Object.assign(Object.assign({}, element), { [property]: value })));
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qrvey/utils",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-6",
|
|
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",
|
|
@@ -21,15 +21,16 @@
|
|
|
21
21
|
"author": "Qrvey Inc",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@compodoc/compodoc": "1.1.19",
|
|
25
|
+
"@types/jest": "27.5.0",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "5.22.0",
|
|
27
|
+
"@typescript-eslint/parser": "5.22.0",
|
|
24
28
|
"eslint": "8.14.0",
|
|
25
29
|
"jest": "27.5.1",
|
|
26
30
|
"np": "7.6.1",
|
|
31
|
+
"ts-jest": "27.1.4",
|
|
27
32
|
"typedoc": "0.22.15",
|
|
28
|
-
"typescript": "4.6.4"
|
|
29
|
-
"@compodoc/compodoc": "1.1.19",
|
|
30
|
-
"@types/jest": "27.4.1",
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "5.22.0",
|
|
32
|
-
"@typescript-eslint/parser": "5.22.0"
|
|
33
|
+
"typescript": "4.6.4"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"d3": "6.3.1",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isEmpty } from '../mix/isEmpty';
|
|
2
|
+
import { isObject } from '../object/isObject';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* It takes an array of objects, adds a property to each object, and returns the new array.
|
|
6
|
+
* @param {Object} info - Information needed to add property to the array of objects.
|
|
7
|
+
* @param {Array} info.array - The array of objects you want to add a property to.
|
|
8
|
+
* @param {string} info.property - The property you want to add to the object.
|
|
9
|
+
* @param {any} info.value - - The value to be added to the array of objects.
|
|
10
|
+
* ----------------------------------------------------------------------------------------------
|
|
11
|
+
* @example <caption>Example usage of addPropertyToArrayOfObjects.</caption>
|
|
12
|
+
* addPropertyToArrayOfObjects({
|
|
13
|
+
* array: [{ name: "John", lastName: "Doe" }, { name: "Chris", lastName: "Musk" }],
|
|
14
|
+
* property: "lastName",
|
|
15
|
+
* value: 'Peck'
|
|
16
|
+
* });
|
|
17
|
+
* @returns the new array created.
|
|
18
|
+
*/
|
|
19
|
+
export function addPropertyToArrayOfObjects(obj: AddPropertyToArrayOfObjectsParams): any[] {
|
|
20
|
+
if (isEmpty(obj) || !isObject(obj)) return [];
|
|
21
|
+
const { array, property, value } = obj;
|
|
22
|
+
if (Array.isArray(array)) {
|
|
23
|
+
if (isEmpty(array) || isEmpty(property)) return array;
|
|
24
|
+
return array.map((element) => ({ ...element, [property]: value }));
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
type AddPropertyToArrayOfObjectsParams = {
|
|
29
|
+
array: any[];
|
|
30
|
+
property: string;
|
|
31
|
+
value: any;
|
|
32
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const { addPropertyToArrayOfObjects } = require('../../../dist/cjs');
|
|
2
|
+
|
|
3
|
+
describe('Testing undefined argument', function () {
|
|
4
|
+
test('no argument passed', function () {
|
|
5
|
+
const validation = addPropertyToArrayOfObjects();
|
|
6
|
+
expect(validation).toEqual([]);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('Undefined argument', function () {
|
|
10
|
+
const validation = addPropertyToArrayOfObjects(undefined);
|
|
11
|
+
expect(validation).toEqual([]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Null argument', function () {
|
|
15
|
+
const validation = addPropertyToArrayOfObjects(null);
|
|
16
|
+
expect(validation).toEqual([]);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('Testing no-object argument', function () {
|
|
21
|
+
const scenarios1 = 1;
|
|
22
|
+
const scenarios2 = false;
|
|
23
|
+
const scenarios4 = 'Hello World';
|
|
24
|
+
const scenarios5 = ['Hello', 'World'];
|
|
25
|
+
|
|
26
|
+
test('Numeric variable', function () {
|
|
27
|
+
const validation = addPropertyToArrayOfObjects(scenarios1);
|
|
28
|
+
expect(validation).toEqual([]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('Boolean variable', function () {
|
|
32
|
+
const validation = addPropertyToArrayOfObjects(scenarios2);
|
|
33
|
+
expect(validation).toEqual([]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('String variable', function () {
|
|
37
|
+
const validation = addPropertyToArrayOfObjects(scenarios4);
|
|
38
|
+
expect(validation).toEqual([]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('Array variable', function () {
|
|
42
|
+
const validation = addPropertyToArrayOfObjects(scenarios5);
|
|
43
|
+
expect(validation).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('Testing invalid object arguments', function () {
|
|
48
|
+
const scenarios1 = { array: undefined, property: 'lastName', value: 'Doe' };
|
|
49
|
+
const scenarios2 = { array: [{ name: 'Lebron', lastName: 'James' }], property: undefined, value: 'Doe' };
|
|
50
|
+
|
|
51
|
+
test('Empty Array', function () {
|
|
52
|
+
const validation = addPropertyToArrayOfObjects(scenarios1);
|
|
53
|
+
expect(validation).toEqual([]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('Empty Property', function () {
|
|
57
|
+
const validation = addPropertyToArrayOfObjects(scenarios2);
|
|
58
|
+
expect(validation).toEqual(scenarios2.array);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('Regular scenarios', function () {
|
|
63
|
+
const commonArray = [
|
|
64
|
+
{ name: 'John', lastName: 'Doe' },
|
|
65
|
+
{ name: 'Chris', lastName: 'Musk' },
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const scenarios1 = { array: commonArray, property: 'name', value: 'Daniel' };
|
|
69
|
+
const scenarios2 = { array: commonArray, property: 'nationality', value: 'Colombian' };
|
|
70
|
+
const scenarios3 = { array: [{ name: 'Lebron', lastName: 'James' }], property: 'lastName', value: undefined };
|
|
71
|
+
|
|
72
|
+
const expectedScenario1 = [
|
|
73
|
+
{ name: 'Daniel', lastName: 'Doe' },
|
|
74
|
+
{ name: 'Daniel', lastName: 'Musk' },
|
|
75
|
+
];
|
|
76
|
+
const expectedScenario2 = [
|
|
77
|
+
{ name: 'John', lastName: 'Doe', nationality: 'Colombian' },
|
|
78
|
+
{ name: 'Chris', lastName: 'Musk', nationality: 'Colombian' },
|
|
79
|
+
];
|
|
80
|
+
const expectedScenario3 = [{ name: 'Lebron', lastName: undefined }];
|
|
81
|
+
|
|
82
|
+
test('Scenario #1', function () {
|
|
83
|
+
const validation = addPropertyToArrayOfObjects(scenarios1);
|
|
84
|
+
expect(validation).toEqual(expectedScenario1);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('Scenario #2', function () {
|
|
88
|
+
const validation = addPropertyToArrayOfObjects(scenarios2);
|
|
89
|
+
expect(validation).toEqual(expectedScenario2);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('Scenario #3', function () {
|
|
93
|
+
const validation = addPropertyToArrayOfObjects(scenarios3);
|
|
94
|
+
expect(validation).toEqual(expectedScenario3);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
|
|
1
|
+
import { isTokenLabel } from '../../src/tokens/isTokenLabel';
|
|
2
2
|
|
|
3
3
|
describe('Testing undefined argument', function () {
|
|
4
4
|
test('no argument passed', function () {
|
|
5
|
-
const validation = isTokenLabel();
|
|
5
|
+
const validation: boolean = isTokenLabel();
|
|
6
6
|
expect(validation).toBeFalsy();
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
test('Undefined argument', function () {
|
|
10
|
-
const validation = isTokenLabel(undefined);
|
|
10
|
+
const validation: boolean = isTokenLabel(undefined);
|
|
11
11
|
expect(validation).toBeFalsy();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
test('Null argument', function () {
|
|
15
|
-
const validation = isTokenLabel(null);
|
|
15
|
+
const validation: boolean = isTokenLabel(null);
|
|
16
16
|
expect(validation).toBeFalsy();
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
describe('Testing no-string arguments', function () {
|
|
21
|
-
const variable1 = 1;
|
|
22
|
-
const variable2 = false;
|
|
23
|
-
const variable3 = new Date();
|
|
24
|
-
const variable4 = { const1: 'Hello', const2: 'World'};
|
|
25
|
-
const variable5 = ['Hello', 'World'];
|
|
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
26
|
|
|
27
27
|
test('Numeric variable', function () {
|
|
28
|
-
const validation = isTokenLabel(variable1);
|
|
28
|
+
const validation: boolean = isTokenLabel(variable1);
|
|
29
29
|
expect(validation).toBeFalsy();
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test('Boolean variable', function () {
|
|
33
|
-
const validation = isTokenLabel(variable2);
|
|
33
|
+
const validation: boolean = isTokenLabel(variable2);
|
|
34
34
|
expect(validation).toBeFalsy();
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
test('Date object variable', function () {
|
|
38
|
-
const validation = isTokenLabel(variable3);
|
|
38
|
+
const validation: boolean = isTokenLabel(variable3);
|
|
39
39
|
expect(validation).toBeFalsy();
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
test('Object variable', function () {
|
|
43
|
-
const validation = isTokenLabel(variable4);
|
|
43
|
+
const validation: boolean = isTokenLabel(variable4);
|
|
44
44
|
expect(validation).toBeFalsy();
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
test('Array variable', function () {
|
|
48
|
-
const validation = isTokenLabel(variable5);
|
|
48
|
+
const validation: boolean = isTokenLabel(variable5);
|
|
49
49
|
expect(validation).toBeFalsy();
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
describe('Testing invalid string argument', function () {
|
|
54
|
-
const variable1 = '';
|
|
55
|
-
const variable2 = 'Hello World';
|
|
56
|
-
const variable3 = '{}';
|
|
57
|
-
const variable4 = '{{}}';
|
|
58
|
-
const variable5 = '{{ }}';
|
|
59
|
-
const variable6 = '{{ Hello }}';
|
|
60
|
-
const variable7 = '{{Hello}';
|
|
61
|
-
const variable8 = '{{Hello}}{{World}}';
|
|
62
|
-
const variable9 = '{Hello}';
|
|
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
63
|
|
|
64
64
|
test('Empty string', function () {
|
|
65
|
-
const validation = isTokenLabel(variable1);
|
|
65
|
+
const validation: boolean = isTokenLabel(variable1);
|
|
66
66
|
expect(validation).toBeFalsy();
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
test('Non-empty and regular string', function () {
|
|
70
|
-
const validation = isTokenLabel(variable2);
|
|
70
|
+
const validation: boolean = isTokenLabel(variable2);
|
|
71
71
|
expect(validation).toBeFalsy();
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
test('Single curly brackets and empty label', function () {
|
|
75
|
-
const validation = isTokenLabel(variable3);
|
|
75
|
+
const validation: boolean = isTokenLabel(variable3);
|
|
76
76
|
expect(validation).toBeFalsy();
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
test('Double curly brackets and empty label', function () {
|
|
80
|
-
const validation = isTokenLabel(variable4);
|
|
80
|
+
const validation: boolean = isTokenLabel(variable4);
|
|
81
81
|
expect(validation).toBeFalsy();
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
test('Double curly brackets and space between them', function () {
|
|
85
|
-
const validation = isTokenLabel(variable5);
|
|
85
|
+
const validation: boolean = isTokenLabel(variable5);
|
|
86
86
|
expect(validation).toBeFalsy();
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('Double curly brackets and non-empty label with space between them', function () {
|
|
90
|
-
const validation = isTokenLabel(variable6);
|
|
90
|
+
const validation: boolean = isTokenLabel(variable6);
|
|
91
91
|
expect(validation).toBeFalsy();
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
test('Double left and single right curly brackets and non-empty label', function () {
|
|
95
|
-
const validation = isTokenLabel(variable7);
|
|
95
|
+
const validation: boolean = isTokenLabel(variable7);
|
|
96
96
|
expect(validation).toBeFalsy();
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('Two data tokens in a single string', function () {
|
|
100
|
-
const validation = isTokenLabel(variable8);
|
|
100
|
+
const validation: boolean = isTokenLabel(variable8);
|
|
101
101
|
expect(validation).toBeFalsy();
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
test('Single curly brackets and non-empty label', function () {
|
|
105
|
-
const validation = isTokenLabel(variable9);
|
|
105
|
+
const validation: boolean = isTokenLabel(variable9);
|
|
106
106
|
expect(validation).toBeFalsy();
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
describe('Regular scenarios', function () {
|
|
111
|
-
const variable1 = '{{NOW}}';
|
|
112
|
-
const variable2 = '{{LAST_YEAR_END}}';
|
|
113
|
-
const variable3 = '{{data.marathonparatooltips-cambiodesorting.FECHA.avg}}';
|
|
111
|
+
const variable1: string = '{{NOW}}';
|
|
112
|
+
const variable2: string = '{{LAST_YEAR_END}}';
|
|
113
|
+
const variable3: string = '{{data.marathonparatooltips-cambiodesorting.FECHA.avg}}';
|
|
114
114
|
|
|
115
115
|
test('Scenario #1', function () {
|
|
116
|
-
const validation = isTokenLabel(variable1);
|
|
116
|
+
const validation: boolean = isTokenLabel(variable1);
|
|
117
117
|
expect(validation).toBeTruthy();
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
test('Scenario #2', function () {
|
|
121
|
-
const validation = isTokenLabel(variable2);
|
|
121
|
+
const validation: boolean = isTokenLabel(variable2);
|
|
122
122
|
expect(validation).toBeTruthy();
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
test('Scenario #3', function () {
|
|
126
|
-
const validation = isTokenLabel(variable3);
|
|
126
|
+
const validation: boolean = isTokenLabel(variable3);
|
|
127
127
|
expect(validation).toBeTruthy();
|
|
128
128
|
});
|
|
129
129
|
});
|