cronapi-js 2.8.19 → 2.9.0

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.
@@ -76,6 +76,9 @@
76
76
  "autoHide": "Ocultar notificação automaticamente",
77
77
  "back": "Voltar para Formulário Anterior",
78
78
  "backDescription": "Volta para formulário aberto anteriormente",
79
+ "breadcrumb": "Breadcrumb",
80
+ "breadcrumbDesc": "Criar uma estrutura de navegação apresentada em uma interface lúdica",
81
+ "breadcrumbParamMap": "Rota",
79
82
  "blocklyWithFunction": "Nome do Bloco",
80
83
  "bottom": "Embaixo",
81
84
  "buttonConfirmDialogAlert": "Botão do modal",
@@ -173,6 +176,9 @@
173
176
  "createExceptionParam0": "Mensagem",
174
177
  "createFile": "Criar Arquivo",
175
178
  "createFileDescription": "Função para criar um arquivo no dispositivo móvel.",
179
+ "createMap": "Criar Mapa com",
180
+ "createMapDesc": "Função que cria um objeto Mapa",
181
+ "createMapVariableParam0": "Valor(es): Valores a serem adicionados no Mapa",
176
182
  "createNewObject": "Criar novo objeto",
177
183
  "createObject": "Criar objeto",
178
184
  "createObjectDescription": "Função que cria um objeto a partir de um texto",
@@ -193,10 +199,26 @@
193
199
  "cssClass": "Classe CSS",
194
200
  "dashboard": "Dashboard",
195
201
  "datasource": "Fonte de dados",
196
- "datasourceFilterDescription": "Função que filtra uma Fonte de dados concatenando '/' e o caminho do parâmetro",
202
+ "datasourceFilterConditionAnd": "E",
203
+ "datasourceFilterConditionOr": "OU",
204
+ "datasourceFilterDescription": "Função que filtra uma Fonte de dados concatenando a partir dos parâmetros informados",
197
205
  "datasourceFilterName": "Filtrar",
206
+ "datasourceFilterName1": "Filtrar dados",
207
+ "datasourceFilterName2": "Criar Filtro",
198
208
  "datasourceFilterParam0": "Fonte de dados",
199
209
  "datasourceFilterParam1": "Caminho",
210
+ "datasourceFilterParam2": "Campo",
211
+ "datasourceFilterParam3": "Operador",
212
+ "datasourceFilterParam4": "Valor",
213
+ "datasourceFilterParam5": "Filtro ou Lista de Filtros",
214
+ "datasourceFilterParam6": "Condição",
215
+ "datasourceFilterOprEq": "Igual",
216
+ "datasourceFilterOprNe": "Diferente",
217
+ "datasourceFilterOprGt": "Maior que",
218
+ "datasourceFilterOprLt": "Menor que",
219
+ "datasourceFilterOprGe": "Maior ou igual a",
220
+ "datasourceFilterOprLe": "Menor ou igual a",
221
+ "datasourceFilterOprSubStr": "Contém",
200
222
  "datasourceFromScreenDescription": "Função que retorna o nome da fonte de dados do formulário",
201
223
  "datasourceFromScreenName": "Obtém Fonte de dados",
202
224
  "datasourceFromScreenParam0": "Fonte de dados",
@@ -249,6 +271,9 @@
249
271
  "fieldNameFromScreen": "Obter nome do campo",
250
272
  "fileName": "Nome do Arquivo",
251
273
  "filterItemParam": "Identificador da repetição",
274
+ "fingerPrintRead": "Ler biometria digital",
275
+ "fingerPrintReadDescription": "Função que inicia o dispositivo para leitura de impressão digital",
276
+ "fingerPrintResult": "0: Autenticação bem sucedida; -1: Falha na autenticação; -2: Dispositivo não suportado",
252
277
  "firstRecordDescription": "Função que põe o cursor no primeiro registro da Fonte de dados",
253
278
  "firstRecordName": "Ir para Primeiro Registro",
254
279
  "firstRecordParam0": "Fonte de dados",
@@ -317,14 +342,14 @@
317
342
  "getBaseUrlName": "Obter Url Base",
318
343
  "getCEPDescription": "Função para buscar os dados do CEP",
319
344
  "getCEPName": "Buscar CEP",
320
- "getCalendarMax": "Obter data máxima",
321
- "getCalendarMaxDesc": "Obtém a data máxima do calendário.",
322
- "getCalendarMin": "Obter data mínima",
323
- "getCalendarMinDesc": "Obtém a data mínima do calendário.",
324
- "getCalendarSelectDates": "Obter datas selecionadas",
325
- "getCalendarSelectDatesDesc": "Obtém a lista de datas selecionadas do calendário. (Disponível apenas caso o modo de seleção do calendário esteja definido para 'Múltipla')",
326
- "getCalendarValue": "Obter data atual",
327
- "getCalendarValueDesc": "Obtém o valor da seleção única atual do calendário.",
345
+ "getCalendarMax":"Obter data máxima",
346
+ "getCalendarMaxDesc":"Obtém a data máxima do calendário.",
347
+ "getCalendarMin":"Obter data mínima",
348
+ "getCalendarMinDesc":"Obtém a data mínima do calendário.",
349
+ "getCalendarSelectDates":"Obter datas selecionadas",
350
+ "getCalendarSelectDatesDesc":"Obtém a lista de datas selecionadas do calendário. (Disponível apenas caso o modo de seleção do calendário esteja definido para 'Múltipla')",
351
+ "getCalendarValue":"Obter data atual",
352
+ "getCalendarValueDesc":"Obtém o valor da seleção única atual do calendário.",
328
353
  "getChatUser": "Obter Usuário do Chat",
329
354
  "getChatUserDesc": "Retorna as informações do usuário atual do Chat",
330
355
  "getChildrenDescription": "Função que retorna uma lista com os elementos filhos do elemento",
@@ -359,6 +384,14 @@
359
384
  "getImageFrom": "Obter imagem da...",
360
385
  "getLocalStorage": "Obter Item da Sessão do navegador",
361
386
  "getLocalStorageDesc": "Função que obtém um item na sessão global do navegador. Esse item é mantido ao fechar o navegador e é visível em todas as abas",
387
+ "getMapValueByKey": "Obter Campo do Mapa por Chave",
388
+ "getMapValueByKeyDesc": "Função para obter Campo do Mapa por Chave",
389
+ "getMapValueByKeyParam0": "Mapa: Mapa que será buscado o Campo",
390
+ "getMapValueByKeyParam1": "Chave: Chave que será buscado, ex: genero",
391
+ "getMapValueByPath": "Obter Campo do Mapa por Caminho",
392
+ "getMapValueByPathDesc": "Função para obter Campo do Mapa por Caminho",
393
+ "getMapValueByPathParam0": "Mapa: Mapa que será buscado o Campo",
394
+ "getMapValueByPathParam1": "Caminho: Caminho que será buscado, ex: documento.rg.emissor",
362
395
  "getMinuteFromDate": "Obter minuto da data",
363
396
  "getMinutesBetweenDates": "Obter total de minutos entre datas",
364
397
  "getMonthFromDate": "Obter mês da data",
@@ -414,7 +447,6 @@
414
447
  "iconUrl": "URL da imagem do usuário",
415
448
  "id": "Id",
416
449
  "idContextMenuParam": "Identificador do menu",
417
- "idAccordion": "Identificador do Acordeão",
418
450
  "idItemListMenuParam": "Abrir no componente",
419
451
  "idsFromScreen": "Obter identificador: Identificador (id) a ser obtido do Formulário selecionado",
420
452
  "incDay": "Incrementar dia na data",
@@ -440,6 +472,12 @@
440
472
  "lastRecordName": "Ir para Último registro",
441
473
  "lastRecordParam0": "Fonte de dados",
442
474
  "left": "Esquerda",
475
+ "listBreadcrumb": "Item do breadcrumb",
476
+ "listBreadcrumbDesc": "Cria um item do caminho do breadcrumb",
477
+ "listBreadcrumbTitulo": "Título",
478
+ "listBreadcrumbLink": "URL",
479
+ "listBreadcrumbIcon": "Ícone",
480
+ "listBreadcrumbRoot": "Item principal?",
443
481
  "loadMoreName": "Carregar mais registros",
444
482
  "loadMoreNameDescription": "Função que chama a próxima página de registros do datasource",
445
483
  "logoutDescription": "Função que faz o logout do usuário",
@@ -588,6 +626,16 @@
588
626
  "setElementValueName": "Definir conteúdo do elemento",
589
627
  "setLocalStorage": "Adicionar Item na Sessão do navegador",
590
628
  "setLocalStorageDesc": "Função que adiciona um item na sessão global do navegador. Esse item é mantido ao fechar o navegador e é visível em todas as abas",
629
+ "setMapValueByKey": "Definir valor no Mapa por Chave",
630
+ "setMapValueByKeyDesc": "Função para Definir Campo no Mapa através de uma determinada Chave",
631
+ "setMapValueByKeyParam0": "Mapa: Mapa que será adicionado o Campo",
632
+ "setMapValueByKeyParam1": "Chave: Chave de Busca no Mapa",
633
+ "setMapValueByKeyParam2": "Valor: Valor a ser definido no Mapa",
634
+ "setMapValueByPath": "Definir valor no Mapa por Caminho",
635
+ "setMapValueByPathDesc": "Função para Definir Campo no Mapa através de um determinado Caminho",
636
+ "setMapValueByPathParam0": "Mapa: Mapa que será adicionado o Campo",
637
+ "setMapValueByPathParam1": "Caminho: Caminho que o Valor será adicionado, ex: documento.rg.emissor",
638
+ "setMapValueByPathParam2": "Valor: Valor a ser definido no Mapa, ex: 'SSP'",
591
639
  "setProperty": "Atribuir valor",
592
640
  "setPropertyDescription": "Função para atribuir o valor ao objeto",
593
641
  "setRequestToken": "Definir Token",
@@ -683,5 +731,5 @@
683
731
  "year": "Ano",
684
732
  "yearsToIncrement": "Anos a incrementar",
685
733
  "yes": "Sim",
686
- "zoom": "Zoom"
734
+ "zoom": "Zoom"
687
735
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "cronapi-js",
3
- "version": "2.8.19",
3
+ "version": "2.9.0",
4
4
  "description": "Public library for CronApp's users",
5
5
  "main": "cronapi.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "jest --coverage",
8
+ "build": "gulp"
8
9
  },
9
10
  "repository": {
10
11
  "type": "git",
@@ -22,14 +23,20 @@
22
23
  "javascript"
23
24
  ],
24
25
  "devDependencies": {
26
+ "@types/chai": "^4.2.14",
27
+ "@types/jest": "^26.0.15",
28
+ "@types/node": "^14.14.6",
29
+ "chai": "^4.2.0",
25
30
  "gulp": "^3.9.1",
26
31
  "gulp-autoprefixer": "^3.1.1",
27
32
  "gulp-babel-minify": "^0.5.0",
33
+ "gulp-cli": "2.2.0",
28
34
  "gulp-notify": "^3.0.0",
29
35
  "gulp-rename": "^1.2.2",
30
36
  "gulp-uglify": "^2.1.2",
31
37
  "gulp-util": "^3.0.8",
32
- "gulp-cli": "2.2.0",
38
+ "jest": "^26.6.3",
39
+ "jquery": "3.5.1",
33
40
  "gulp-concat": "2.6.1"
34
41
  },
35
42
  "dependencies": {
@@ -0,0 +1,17 @@
1
+ describe('Test suit for category chart from Cronapi.js', function() {
2
+ const ch = require('chai');
3
+ ch.should();
4
+
5
+ let {window} = require('../../../../../cronapi');
6
+ const cronapi = window["cronapi"];
7
+
8
+ it('createChart', function() {
9
+ });
10
+
11
+ it('createDataset', function() {
12
+ var element = document.querySelector('#user');
13
+ let value = cronapi.chart.createDataset(element, element, element);
14
+ value.should.eql({"data": [], "label": "", "options": null});
15
+ });
16
+
17
+ });
@@ -0,0 +1,127 @@
1
+ describe('Test suit for category conversion from Cronapi.js',
2
+ function() {
3
+ const ch = require('chai');
4
+ let {window} = require('../../../../../cronapi');
5
+ ch.should();
6
+ const cronapi = window["cronapi"];
7
+
8
+ it('asciiToBinary', function() {
9
+ let value = cronapi.conversion.asciiToBinary.bind(window)('hello');
10
+ value.should.equal('0110100001100101011011000110110001101111');
11
+
12
+ value = cronapi.conversion.asciiToBinary.bind(window)('');
13
+ value.should.equal('');
14
+ });
15
+
16
+ it('toBoolean', function() {
17
+ let value = cronapi.conversion.toBoolean.bind(window)(true);
18
+ value.should.equal(true);
19
+
20
+ value = cronapi.conversion.toBoolean.bind(window)(false);
21
+ value.should.equal(false);
22
+
23
+ value = cronapi.conversion.toBoolean.bind(window)(null);
24
+ value.should.equal(false);
25
+
26
+ value = cronapi.conversion.toBoolean.bind(window)('1');
27
+ value.should.equal(true);
28
+
29
+ value = cronapi.conversion.toBoolean.bind(window)('true');
30
+ value.should.equal(true);
31
+ });
32
+
33
+ it('toBytes', function() {
34
+ let value = cronapi.conversion.toBytes.bind(window)();
35
+ value.should.equal('');
36
+
37
+ value = cronapi.conversion.toBytes.bind(window)(null);
38
+ value.should.equal('');
39
+
40
+ value = cronapi.conversion.toBytes.bind(window)(undefined);
41
+ value.should.equal('');
42
+
43
+ value = cronapi.conversion.toBytes.bind(window)(10);
44
+ value.should.equal('10');
45
+ });
46
+
47
+ it('chrToAscii ', function() {
48
+ let value = cronapi.conversion.chrToAscii.bind(window)();
49
+ (value === null).should.equal(true);
50
+
51
+ value = cronapi.conversion.chrToAscii.bind(window)(null);
52
+ (value === null).should.equal(true);
53
+
54
+ value = cronapi.conversion.chrToAscii.bind(window)(undefined);
55
+ (value === null).should.equal(true);
56
+
57
+ value = cronapi.conversion.chrToAscii.bind(window)('h');
58
+ value.should.equal(104);
59
+
60
+ value = cronapi.conversion.chrToAscii.bind(window)('hello');
61
+ value.should.equal(104);
62
+ });
63
+
64
+ it('stringToJs', function() {
65
+ let value = cronapi.conversion.stringToJs.bind(window)('{"usename": "admin", "password": 123}');
66
+ value.should.equal('{\\"usename\\": \\"admin\\", \\"password\\": 123}');
67
+ });
68
+
69
+ it('stringToDate', function() {
70
+ const validDate = new Date(2020, 10, 13);
71
+
72
+ let value = cronapi.conversion.stringToDate.bind(window)(validDate);
73
+ value.should.equal(validDate);
74
+
75
+ value = cronapi.conversion.stringToDate.bind(window)(null);
76
+ (value === null).should.equal(true);
77
+
78
+ value = cronapi.conversion.stringToDate.bind(window)(undefined);
79
+ (value === null).should.equal(true);
80
+
81
+ value = cronapi.conversion.stringToDate.bind(window)('2020-11');
82
+ (value.toUTCString()).should.equal(new Date("Sun Nov 01 2020 00:00:00 GMT-0000").toUTCString());
83
+
84
+ Object.defineProperty(window.navigator, 'language', { value: 'es-Es', writable: true, configurable: true });
85
+ value = cronapi.conversion.stringToDate.bind(window)('2020-11-13');
86
+ (value.toUTCString()).should.equal(new Date("Sun Nov 13 2020 00:00:00 GMT-0000").toUTCString());
87
+
88
+ // Os três casos abaixo contemplariam o restante da cobertura, não ficou totalmente
89
+ // funcional porque não foi possível mockar as funções internas chamadas
90
+ // pelo eval: cronapi.internal.enDate e cronapi.internal.enDate
91
+
92
+ Object.defineProperty(window.navigator, 'language', { value: 'en-Us' });
93
+ // value = cronapi.conversion.stringToDate.bind(window)('10-13-2020');
94
+ // value.should.equal(validDate);
95
+
96
+ // Object.defineProperty(window.navigator, 'language', { value: 'pt-BR', writable: true });
97
+ // value = cronapi.conversion.stringToDate.bind(window)('13-10-2020');
98
+ // value.should.equal(validDate);
99
+
100
+ // Object.defineProperty(window.navigator, 'language', { value: null });
101
+ // Object.defineProperty(window.navigator, 'userLanguage', { value: 'pt-BR', writable: true });
102
+ // value = cronapi.conversion.stringToDate.bind(window)('13-10-2020');
103
+ // value.should.equal(validDate);
104
+ });
105
+
106
+ it('intToHex', function() {
107
+ let value = cronapi.conversion.intToHex.bind(window)(10);
108
+ value.should.equal('A');
109
+ });
110
+
111
+ it('toLong', function() {
112
+ let value = cronapi.conversion.toLong.bind(window)('10');
113
+ value.should.equal(10);
114
+ });
115
+
116
+ it('toString', function() {
117
+ let value = cronapi.conversion.toString.bind(window)(10);
118
+ value.should.equal('10');
119
+
120
+ value = cronapi.conversion.toString.bind(window)(null);
121
+ value.should.equal('');
122
+
123
+ value = cronapi.conversion.toString.bind(window)(undefined);
124
+ value.should.equal('');
125
+ });
126
+
127
+ });
@@ -0,0 +1,59 @@
1
+ describe('Test suit for category json from Cronapi.js',
2
+ function() {
3
+ const ch = require('chai');
4
+ let {window} = require('../../../../../cronapi');
5
+ ch.should();
6
+ const cronapi = window["cronapi"];
7
+
8
+ it('createObjectFromString', function() {
9
+ let value = cronapi.json.createObjectFromString.bind(window)('{"user": {"username": "admin"}}');
10
+ (JSON.stringify(value)).should.equal('{"user":{"username":"admin"}}');
11
+ });
12
+
13
+ it('setProperty', function() {
14
+ let user = {};
15
+ user['username'] = 'admin';
16
+ user['password'] = '123';
17
+ user['info'] = {name: 'Administrator', birthday: '01/01/2000'};
18
+
19
+ cronapi.json.setProperty.bind(window)(user, 'username', 'john');
20
+ let value = cronapi.json.getProperty.bind(window)(user, 'username');
21
+ value.should.equal('john');
22
+
23
+ cronapi.json.setProperty.bind(window)(user, 'info.name', 'John');
24
+ value = cronapi.json.getProperty.bind(window)(user, 'info.name');
25
+ value.should.equal('John');
26
+
27
+ user['info'] = {name: 'Administrator', birthday: undefined};
28
+ cronapi.json.setProperty.bind(window)(user, 'info.birthday', undefined);
29
+ value = cronapi.json.getProperty.bind(window)(user, 'info.birthday');
30
+ (JSON.stringify(value)).should.equal('{}');
31
+ });
32
+
33
+ it('deleteProperty', function() {
34
+ let user = {};
35
+ user['username'] = 'admin';
36
+ user['password'] = '123';
37
+ user['info'] = {name: 'Administrator', birthday: '01/01/2000'};
38
+
39
+ cronapi.json.deleteProperty.bind(window)(user, "info");
40
+ let value = cronapi.json.getProperty.bind(window)(user, "info");
41
+ (value === undefined).should.equal(true);
42
+ });
43
+
44
+ it('getProperty', function() {
45
+ let user = {};
46
+ user['username'] = 'admin';
47
+ user['password'] = '123';
48
+ user['info'] = {name: 'Administrator', birthday: undefined};
49
+
50
+ let value = cronapi.json.getProperty.bind(window)(user, 'username');
51
+ value.should.equal('admin');
52
+
53
+ value = cronapi.json.getProperty.bind(window)(user, 'info.name');
54
+ value.should.equal('Administrator');
55
+
56
+ value = cronapi.json.getProperty.bind(window)(user, 'info.birthday');
57
+ (JSON.stringify(value)).should.equal('{}');
58
+ });
59
+ });
@@ -0,0 +1,43 @@
1
+ describe('Test suit for category logic from Cronapi.js', function() {
2
+ const ch = require('chai');
3
+ ch.should();
4
+
5
+ let {window} = require('../../../../../cronapi');
6
+ const cronapi = window["cronapi"];
7
+
8
+ it('isNull', function() {
9
+ let value = cronapi.logic.isNull.bind(window)(null);
10
+ value.should.eql(true);
11
+
12
+ value = cronapi.logic.isNull.bind(window)('undefined');
13
+ value.should.eql(false);
14
+ });
15
+
16
+ it('isEmpty', function() {
17
+ let value = cronapi.logic.isEmpty.bind(window)('');
18
+ value.should.eql(true);
19
+ });
20
+
21
+ it('isNullOrEmpty', function() {
22
+ let value = cronapi.logic.isNullOrEmpty.bind(window)(null);
23
+ value.should.eql(true);
24
+
25
+ value = cronapi.logic.isNullOrEmpty.bind(window)('undefined');
26
+ value.should.eql(false);
27
+
28
+ value = cronapi.logic.isNullOrEmpty.bind(window)('');
29
+ value.should.eql(true);
30
+ });
31
+
32
+ it('typeOf', function() {
33
+ let value = cronapi.logic.typeOf.bind(window)(null, 'array');
34
+ value.should.eql(false);
35
+
36
+ value = cronapi.logic.typeOf.bind(window)(new Array(), 'object');
37
+ value.should.eql(false);
38
+
39
+ value = cronapi.logic.typeOf.bind(window)(null, 'object');
40
+ value.should.eql(false);
41
+ });
42
+
43
+ });
@@ -0,0 +1,52 @@
1
+
2
+ describe('Test suit for category map from Cronapi.js',
3
+ function() {
4
+
5
+ const ch = require('chai');
6
+ let {window} = require('../../../../../cronapi');
7
+ ch.should();
8
+ const cronapi = window["cronapi"];
9
+
10
+ let mapCreated;
11
+
12
+ beforeAll(() => {
13
+ let map = [
14
+ {"param1" : {"name":"John", "age":30, "car":null}},
15
+ {"param2" : {"name":"Marie"}},
16
+ {"param3" : "Chic"},
17
+ ]
18
+ mapCreated = cronapi.map.createMap.bind(window)(map);
19
+ });
20
+
21
+ it('createMap', function() {
22
+ (mapCreated[0].param1.car === null).should.equal(true);
23
+ (mapCreated[0].param1.age === 30).should.equal(true);
24
+ (mapCreated[1].param2.name === "Marie").should.equal(true);
25
+ (mapCreated[2].param3 === "Chic").should.equal(true);
26
+ });
27
+
28
+ it('setMapValueByKey', function() {
29
+ cronapi.map.setMapValueByKey.bind(window)(mapCreated, "param4", "Brasil");
30
+ (mapCreated[3].param4 === "Brasil").should.equal(true);
31
+ });
32
+
33
+ it('setMapValueByPath', function() {
34
+ cronapi.map.setMapValueByPath.bind(window)(mapCreated, "param5.lowcode.platform", "Cronapp");
35
+ (mapCreated[4].param5 !== null).should.equal(true);
36
+ (mapCreated[4].param5.lowcode !== null).should.equal(true);
37
+ (mapCreated[4].param5.lowcode.platform === "Cronapp").should.equal(true);
38
+ });
39
+
40
+ it('getMapValueByPath', function() {
41
+ const result = cronapi.map.getMapValueByPath.bind(window)(mapCreated, "param5.lowcode.platform");
42
+ (result !== null).should.equal(true);
43
+ (result === "Cronapp").should.equal(true);
44
+ });
45
+
46
+ it('getMapValueByKey', function() {
47
+ const result = cronapi.map.getMapValueByKey.bind(window)(mapCreated, "param3");
48
+ (result !== null).should.equal(true);
49
+ (result === "Chic").should.equal(true);
50
+ });
51
+
52
+ });
@@ -0,0 +1,106 @@
1
+ describe('Test suit for category object from Cronapi.js',
2
+ function() {
3
+ const ch = require('chai');
4
+ let {window} = require('../../../../../cronapi');
5
+ ch.should();
6
+ const cronapi = window["cronapi"];
7
+
8
+ it('getProperty', function() {
9
+ let user = {};
10
+ user['username'] = 'admin';
11
+ user['password'] = '123';
12
+ user['info'] = {name: 'Administrator', birthday: undefined};
13
+
14
+ let value = cronapi.object.getProperty.bind(window)(user, 'username');
15
+ value.should.equal('admin');
16
+
17
+ value = cronapi.object.getProperty.bind(window)(user, 'info.name');
18
+ value.should.equal('Administrator');
19
+
20
+ value = cronapi.object.getProperty.bind(window)(user, 'info.birthday');
21
+ (JSON.stringify(value)).should.equal('{}');
22
+ });
23
+
24
+ it('setProperty', function() {
25
+ let user = {};
26
+ user['username'] = 'admin';
27
+ user['password'] = '123';
28
+ user['info'] = {name: 'Administrator', birthday: '01/01/2000'};
29
+
30
+ cronapi.object.setProperty.bind(window)(user, 'username', 'john');
31
+ let value = cronapi.object.getProperty.bind(window)(user, 'username');
32
+ value.should.equal('john');
33
+
34
+ cronapi.object.setProperty.bind(window)(user, 'info.name', 'John');
35
+ value = cronapi.object.getProperty.bind(window)(user, 'info.name');
36
+ value.should.equal('John');
37
+
38
+ user['info'] = {name: 'Administrator', birthday: undefined};
39
+ cronapi.object.setProperty.bind(window)(user, 'info.birthday', undefined);
40
+ value = cronapi.object.getProperty.bind(window)(user, 'info.birthday');
41
+ (JSON.stringify(value)).should.equal('{}');
42
+ });
43
+
44
+ it('createObjectFromString', function() {
45
+ let value = cronapi.object.createObjectFromString.bind(window)('{"user": {"username": "admin"}}');
46
+ (JSON.stringify(value)).should.equal('{"user":{"username":"admin"}}');
47
+ });
48
+
49
+ it('createObjectLoginFromString', function() {
50
+ let value = cronapi.object.createObjectLoginFromString.bind(window)("admin", 123);
51
+ (JSON.stringify(value)).should.equal('{"username":"admin","password":123}');
52
+ });
53
+
54
+ it('serializeObject', function() {
55
+ let value = cronapi.object.serializeObject.bind(window)({username:"admin", password: 123});
56
+ value.should.equal('{"username":"admin","password":123}');
57
+ });
58
+
59
+ it('deleteProperty', function() {
60
+ let user = {};
61
+ user['username'] = 'admin';
62
+ user['password'] = '123';
63
+ user['info'] = {name: 'Administrator', birthday: '01/01/2000'};
64
+
65
+ cronapi.object.deleteProperty.bind(window)(user, "info");
66
+ let value = cronapi.object.getProperty(user, "info");
67
+ (value === undefined).should.equal(true);
68
+ });
69
+
70
+ it('newObject', function() {
71
+ let user = {};
72
+ user['username'] = 'admin';
73
+ user['password'] = '123';
74
+ user['info'] = {name: 'Administrator', birthday: '01/01/2000'};
75
+
76
+ let value = cronapi.object.newObject.bind(window)();
77
+ (JSON.stringify(value)).should.equal('{}');
78
+
79
+ value = cronapi.object.newObject.bind(window)({username: 'admin'});
80
+ (JSON.stringify(value)).should.equal('{}');
81
+
82
+ value = cronapi.object.newObject.bind(window)({name: 'username', value: 'admin'});
83
+ (JSON.stringify(value)).should.equal('{"username":"admin"}');
84
+ });
85
+
86
+ it('getObjectField', function() {
87
+ let user = {};
88
+ user['username'] = 'admin';
89
+
90
+ let value = cronapi.object.getObjectField.bind(window)(user, null);
91
+ (value === undefined).should.equal(true);
92
+
93
+ value = cronapi.object.getObjectField.bind(window)(user, undefined);
94
+ (value === undefined).should.equal(true);
95
+
96
+ value = cronapi.object.getObjectField.bind(window)(null, 'username');
97
+ (value === undefined).should.equal(true);
98
+
99
+ value = cronapi.object.getObjectField.bind(window)(undefined, 'username');
100
+ (value === undefined).should.equal(true);
101
+
102
+ value = cronapi.object.getObjectField.bind(window)(user, 'username');
103
+ value.should.equal('admin');
104
+ });
105
+
106
+ });
@@ -0,0 +1,44 @@
1
+ describe('Test suit for category regex from Cronapi.js', function() {
2
+
3
+ const chai = require('chai');
4
+ chai.should();
5
+ let expect = chai.expect;
6
+ let {window} = require('../../../../../cronapi');
7
+ const cronapi = window["cronapi"];
8
+
9
+ it('extractTextByRegex', function() {
10
+ let result;
11
+
12
+ result = cronapi.regex.extractTextByRegex.bind(window)(null, '[0-9]', 'g');
13
+ expect(result).to.be.empty;
14
+
15
+ result = cronapi.regex.extractTextByRegex.bind(window)('abcde1234', null, 'g');
16
+ expect(result).to.be.empty;
17
+
18
+ result = cronapi.regex.extractTextByRegex.bind(window)('20/dec/2018', '$[0-9]{4}', null);
19
+ expect(result).to.be.empty;
20
+
21
+ // For sem a declaração correta da variável
22
+ // A Interação com o matches.length só pega a partir da segunda sequencia
23
+ // O retorno vem dentro de 2 Arrays sem necessidade
24
+ result = cronapi.regex.extractTextByRegex.bind(window)('cdbbdbsbz', 'd(b+)d', 'g');
25
+ expect(result).to.be.an.instanceof(Array);
26
+ expect(result).to.be.an('array').that.includes('bb');
27
+ });
28
+
29
+ it('validateTextWithRegex', function() {
30
+ let result;
31
+ result = cronapi.regex.validateTextWithRegex.bind(window)(null, '[0-9]', 'g');
32
+ expect(result).to.be.false;
33
+
34
+ result = cronapi.regex.validateTextWithRegex.bind(window)('12345', null, 'g');
35
+ expect(result).to.be.false;
36
+
37
+ result = cronapi.regex.validateTextWithRegex.bind(window)('Olá Cronapp', '^Ol', null);
38
+ expect(result).to.be.true;
39
+
40
+ result = cronapi.regex.validateTextWithRegex.bind(window)('Cronapp is the BEST low code', 'best', 'gi');
41
+ expect(result).to.be.true;
42
+ });
43
+
44
+ });