cronapi-js 2.8.34 → 2.9.1-SP.10
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/cronapi.js +1138 -299
- package/dist/cronapi.min.js +16 -2
- package/i18n/locale_en_us.json +1519 -4
- package/i18n/locale_pt_br.json +1520 -6
- package/package.json +10 -3
- package/test/src/test/cronapi/chart/chart.spec.ts +17 -0
- package/test/src/test/cronapi/cronversion/conversion.spec.ts +127 -0
- package/test/src/test/cronapi/json/json.spec.ts +59 -0
- package/test/src/test/cronapi/logic/logic.spec.ts +43 -0
- package/test/src/test/cronapi/map/map.spec.ts +52 -0
- package/test/src/test/cronapi/object/object.spec.ts +106 -0
- package/test/src/test/cronapi/regex/regex.spec.ts +44 -0
- package/test/src/test/cronapi/screen/screen.spec.ts +425 -0
- package/test/src/test/cronapi/text/text.spec.ts +57 -0
- package/test/src/test/cronapi/util/util.spec.ts +28 -0
- package/test/src/test/cronapi/xml/xml.spec.ts +86 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
describe('Test suit for category Screen from Cronapi.js', function() {
|
|
2
|
+
|
|
3
|
+
const chai = require('chai');
|
|
4
|
+
chai.should();
|
|
5
|
+
let {window} = require('../../../../../cronapi');
|
|
6
|
+
const cronapi = window["cronapi"];
|
|
7
|
+
let dataSource;
|
|
8
|
+
window.$ = require('jquery');
|
|
9
|
+
const $ = window.$;
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
jest.resetAllMocks();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
dataSource = {
|
|
17
|
+
data: [],
|
|
18
|
+
$apply: function (fun) {
|
|
19
|
+
if (fun instanceof Function) {
|
|
20
|
+
fun();
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
startInserting: () => { dataSource.data.push({ company: 'Techne', category: 'Cronapp' }); },
|
|
24
|
+
startEditing: () => { dataSource.data.company = 'Bahia'; },
|
|
25
|
+
previous: jest.fn(),
|
|
26
|
+
next: jest.fn(),
|
|
27
|
+
removeSilent: jest.fn(),
|
|
28
|
+
refreshActive: jest.fn(),
|
|
29
|
+
hasNext: () => { return true },
|
|
30
|
+
postSilent: () => { return dataSource.data[0].category; },
|
|
31
|
+
isOData: () => { return true },
|
|
32
|
+
search: jest.fn(),
|
|
33
|
+
fetch: jest.fn(),
|
|
34
|
+
hasNextPage: () => { return true },
|
|
35
|
+
nextPage: jest.fn()
|
|
36
|
+
}
|
|
37
|
+
return dataSource;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('isInsertingMode', () => {
|
|
41
|
+
let datasource = {};
|
|
42
|
+
|
|
43
|
+
(cronapi.screen.isInsertingMode(datasource) == undefined).should.equal(true);
|
|
44
|
+
|
|
45
|
+
datasource['inserting'] = true;
|
|
46
|
+
cronapi.screen.isInsertingMode(datasource).should.equal(true);
|
|
47
|
+
|
|
48
|
+
datasource['inserting'] = false;
|
|
49
|
+
cronapi.screen.isInsertingMode(datasource).should.equal(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('isEditingMode', () => {
|
|
53
|
+
let datasource = {};
|
|
54
|
+
|
|
55
|
+
(cronapi.screen.isEditingMode(datasource) == undefined).should.equal(true);
|
|
56
|
+
|
|
57
|
+
datasource['editing'] = true;
|
|
58
|
+
cronapi.screen.isEditingMode(datasource).should.equal(true);
|
|
59
|
+
|
|
60
|
+
datasource['editing'] = false;
|
|
61
|
+
cronapi.screen.isEditingMode(datasource).should.equal(false);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('changeTitleScreen', () => {
|
|
65
|
+
(window.document.title).should.equal('');
|
|
66
|
+
|
|
67
|
+
cronapi.screen.changeTitleScreen();
|
|
68
|
+
(window.document.title).should.equal('undefined');
|
|
69
|
+
|
|
70
|
+
cronapi.screen.changeTitleScreen('Cronapp Low Code');
|
|
71
|
+
(window.document.title).should.equal('Cronapp Low Code');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('fieldFromScreen', () => {
|
|
75
|
+
(cronapi.screen.fieldFromScreen() == undefined).should.equal(true);
|
|
76
|
+
(cronapi.screen.fieldFromScreen(null) == null).should.equal(true);
|
|
77
|
+
cronapi.screen.fieldFromScreen('Cronapp').should.equal('Cronapp');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('changeValueOfField', () => {
|
|
81
|
+
window.__name = 'Cronapp';
|
|
82
|
+
window.__name.should.equal('Cronapp');
|
|
83
|
+
cronapi.screen.changeValueOfField.bind(window)('cronapi.__name', 'Bahia');
|
|
84
|
+
/**
|
|
85
|
+
* O valor do Campo não foi trocado
|
|
86
|
+
*/
|
|
87
|
+
window.__name.should.equal('Bahia');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('getValueOfField', () => {
|
|
91
|
+
(cronapi.screen.getValueOfField.bind(window)() == '').should.equal(true);
|
|
92
|
+
|
|
93
|
+
(cronapi.screen.getValueOfField.bind(window)('cronapi.__name') == 'Cronapp').should.equal(true);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Ao passar um field não encontrado, a lógica não segue o fluxo correto do método
|
|
97
|
+
* if(fieldValue !== undefined || fieldValue !== null)
|
|
98
|
+
* Como não foi encontrado a chave, a condição vai ficar FALSE || TRUE = TRUE, logo
|
|
99
|
+
* será sempre retornado UNDEFINED
|
|
100
|
+
*/
|
|
101
|
+
(cronapi.screen.getValueOfField.bind(window)('cronapi.__city') == '').should.equal(true);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('createScopeVariable', () => {
|
|
105
|
+
cronapi['$scope'] = {}
|
|
106
|
+
cronapi.$scope['vars'] = {};
|
|
107
|
+
cronapi.screen.createScopeVariable.bind(window)('cronapp', 'low code');
|
|
108
|
+
JSON.stringify(cronapi.$scope.vars).should.equal('{"cronapp":"low code"}');
|
|
109
|
+
|
|
110
|
+
cronapi.screen.createScopeVariable.bind(window)('hello', 'world');
|
|
111
|
+
cronapi.$scope.vars.hello.should.equal('world');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('getScopeVariable', () => {
|
|
115
|
+
cronapi.screen.getScopeVariable.bind(window)('cronapp').should.equal('low code');
|
|
116
|
+
|
|
117
|
+
cronapi.screen.getScopeVariable.bind(window)('hello').should.equal('world');
|
|
118
|
+
|
|
119
|
+
(cronapi.screen.getScopeVariable.bind(window)('teste') == undefined).should.equal(true);
|
|
120
|
+
|
|
121
|
+
cronapi.screen.createScopeVariable.bind(window)('logico', false);
|
|
122
|
+
cronapi.screen.getScopeVariable.bind(window)('logico').should.equal(false);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('notify', () => {
|
|
126
|
+
cronapi['$scope'] = {};
|
|
127
|
+
cronapi.$scope['Notification'] = function (json, type) {
|
|
128
|
+
this.json = json;
|
|
129
|
+
this.type = type;
|
|
130
|
+
}
|
|
131
|
+
cronapi.screen.notify.bind(window)();
|
|
132
|
+
JSON.stringify(cronapi.$scope.json).should.equal('{"message":""}');
|
|
133
|
+
cronapi.screen.notify.bind(window)('Successful', 'Cronapp is The Best!');
|
|
134
|
+
JSON.stringify(cronapi.$scope.json).should.equal('{"message":"Cronapp is The Best!"}');
|
|
135
|
+
cronapi.$scope.type.should.equal('Successful');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('datasourceFromScreen', () => {
|
|
139
|
+
cronapi.screen.startInsertingMode.bind(window)(dataSource);
|
|
140
|
+
cronapi.screen.datasourceFromScreen(dataSource).should.equal(dataSource);
|
|
141
|
+
cronapi.screen.datasourceFromScreen(dataSource.data[0].company).should.equal('Techne');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('startInsertingMode', () => {
|
|
145
|
+
cronapi.screen.startInsertingMode.bind(window)(dataSource);
|
|
146
|
+
dataSource.data[0].company.should.equal('Techne');
|
|
147
|
+
dataSource.data[0].category.should.equal('Cronapp');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('startEditingMode', () => {
|
|
151
|
+
cronapi.screen.startEditingMode.bind(window)(dataSource);
|
|
152
|
+
dataSource.data[0].company.should.equal('Techne');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('previusRecord', () => {
|
|
156
|
+
cronapi.screen.previusRecord.bind(window)(dataSource);
|
|
157
|
+
expect(dataSource.previous).toHaveBeenCalledTimes(1);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('nextRecord', () => {
|
|
161
|
+
cronapi.screen.nextRecord.bind(window)(dataSource);
|
|
162
|
+
expect(dataSource.next).toHaveBeenCalledTimes(1);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('firstRecord', () => {
|
|
166
|
+
cronapi.screen.firstRecord.bind(window)(dataSource);
|
|
167
|
+
expect(dataSource.next).toHaveBeenCalledTimes(1);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('lastRecord', () => {
|
|
171
|
+
cronapi.screen.lastRecord.bind(window)(dataSource);
|
|
172
|
+
expect(dataSource.next).toHaveBeenCalledTimes(1);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('removeRecord', () => {
|
|
176
|
+
cronapi.screen.removeRecord.bind(window)(dataSource);
|
|
177
|
+
expect(dataSource.removeSilent).toHaveBeenCalledTimes(1);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('refreshActiveRecord', () => {
|
|
181
|
+
cronapi.screen.refreshActiveRecord.bind(window)(dataSource);
|
|
182
|
+
expect(dataSource.refreshActive).toHaveBeenCalledTimes(1);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('hasNextRecord', () => {
|
|
186
|
+
cronapi.screen.hasNextRecord.bind(window)(dataSource).should.equal(true);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('quantityRecords', () => {
|
|
190
|
+
cronapi.screen.quantityRecords.bind(window)(dataSource).should.equal(2);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('post', () => {
|
|
194
|
+
cronapi.screen.post.bind(window)(dataSource).should.equal('Cronapp');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('filter', () => {
|
|
198
|
+
cronapi.screen.filter.bind(window)(dataSource, 'oData');
|
|
199
|
+
expect(dataSource.search).toBeCalledTimes(1);
|
|
200
|
+
|
|
201
|
+
let data = {
|
|
202
|
+
isOData: () => {
|
|
203
|
+
return false;
|
|
204
|
+
},
|
|
205
|
+
filter: jest.fn()
|
|
206
|
+
}
|
|
207
|
+
cronapi.screen.filter.bind(window)(data, 'any');
|
|
208
|
+
expect(data.filter).toBeCalledTimes(1);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('changeView', () => {
|
|
212
|
+
const { location } = window;
|
|
213
|
+
delete window.location;
|
|
214
|
+
window.location = { reload: jest.fn() };
|
|
215
|
+
window.alert = jest.fn();
|
|
216
|
+
|
|
217
|
+
let listParams = [
|
|
218
|
+
{ company: 'Cronapp' }, { category: 'LowCode' }, { date: new Date() }
|
|
219
|
+
];
|
|
220
|
+
|
|
221
|
+
cronapi.$scope['$state'] = {
|
|
222
|
+
get() {
|
|
223
|
+
return [ { templateUrl: 'views/login.view.html', url: 'login.view.html' } ];
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
cronapi.screen.changeView.bind(window)('view/user/login', listParams);
|
|
228
|
+
|
|
229
|
+
expect(window.location.reload).not.toHaveBeenCalled();
|
|
230
|
+
|
|
231
|
+
cronapi.$scope['$state'] = {
|
|
232
|
+
get() {
|
|
233
|
+
return [ { templateUrl: () => {
|
|
234
|
+
'views/login.view.html'
|
|
235
|
+
}, url: 'login.view.html' } ];
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
cronapi.screen.changeView.bind(window)('view/user/login', listParams);
|
|
240
|
+
|
|
241
|
+
expect(window.location.reload).toBeCalledTimes(1);
|
|
242
|
+
|
|
243
|
+
cronapi.screen.changeView.bind(window)('view/user/login');
|
|
244
|
+
|
|
245
|
+
expect(window.location.reload).toBeCalledTimes(2);
|
|
246
|
+
|
|
247
|
+
cronapi.$scope['$state'] = {
|
|
248
|
+
get() {
|
|
249
|
+
return [ { templateUrl: 'none', url: 'none' } ];
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
cronapi.screen.changeView.bind(window)('view/user/login');
|
|
254
|
+
|
|
255
|
+
expect(window.location.reload).toBeCalledTimes(2);
|
|
256
|
+
|
|
257
|
+
cronapi.screen.changeView.bind(window)('view/user/login?');
|
|
258
|
+
|
|
259
|
+
expect(window.location.reload).toBeCalledTimes(3);
|
|
260
|
+
|
|
261
|
+
expect(window.alert).toBeCalledTimes(1);
|
|
262
|
+
|
|
263
|
+
window.location = location;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('openUrl', () => {
|
|
267
|
+
window.open = jest.fn();
|
|
268
|
+
|
|
269
|
+
cronapi.screen.openUrl.bind(window)('google.com.br', true, 500, 500);
|
|
270
|
+
expect(window.open).toHaveBeenCalled();
|
|
271
|
+
|
|
272
|
+
cronapi.screen.openUrl.bind(window)('google.com.br', 'TRUE', 500, 500);
|
|
273
|
+
expect(window.open).toHaveBeenCalledTimes(2);
|
|
274
|
+
|
|
275
|
+
jest.clearAllMocks();
|
|
276
|
+
|
|
277
|
+
cronapi.screen.openUrl('google.com.br', 'TRUE', 'Cronapp', 500);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it('getParam', () => {
|
|
281
|
+
const { location } = window;
|
|
282
|
+
delete window.location;
|
|
283
|
+
|
|
284
|
+
(cronapi.screen.getParam() == null).should.equal(true);
|
|
285
|
+
|
|
286
|
+
Object.defineProperty(window, 'location', {
|
|
287
|
+
value: {
|
|
288
|
+
href: 'http://example.com/path?name=Techne&products=[Cronapp,LowCode,Dev]&state=Bahia%20Brasil'
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
cronapi.screen.getParam('state').should.equal('Bahia Brasil');
|
|
293
|
+
|
|
294
|
+
expect(cronapi.screen.getParam('products')).toContain('Cronapp');
|
|
295
|
+
|
|
296
|
+
window.location = location;
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('confimDialog', () => {
|
|
300
|
+
window.confirm = jest.fn();
|
|
301
|
+
|
|
302
|
+
cronapi.screen.confimDialog('Cronapp');
|
|
303
|
+
expect(window.confirm).toHaveBeenCalled();
|
|
304
|
+
expect(window.confirm).toHaveBeenCalledTimes(1);
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
it('createDefaultModal', () => {
|
|
308
|
+
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
it('showModal', () => {
|
|
312
|
+
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('setActiveTab', () => {
|
|
316
|
+
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('hideModal', () => {
|
|
320
|
+
document.body.innerHTML =
|
|
321
|
+
'<div id="myModal" class="modal">'
|
|
322
|
+
'<div class="modal-content">'
|
|
323
|
+
'<p>Some text in the Modal..</p>'
|
|
324
|
+
'</div>'
|
|
325
|
+
'</div>'
|
|
326
|
+
|
|
327
|
+
cronapi.screen.hideModal('myModal');
|
|
328
|
+
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('showIonicModal', () => {
|
|
332
|
+
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('hideIonicModal', () => {
|
|
336
|
+
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('isShownIonicModal', () => {
|
|
340
|
+
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('showLoading', () => {
|
|
344
|
+
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('hide', () => {
|
|
348
|
+
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('getHostapp', () => {
|
|
352
|
+
(cronapi.screen.getHostapp() == undefined).should.equal(true);
|
|
353
|
+
window.hostApp = 'Cronapp';
|
|
354
|
+
cronapi.screen.getHostapp().should.equal('Cronapp');
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it('searchIds', () => {
|
|
358
|
+
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it('showComponent', () => {
|
|
362
|
+
document.body.innerHTML = '<div id="cronapp">Low Code</div>';
|
|
363
|
+
$("#cronapp").get(0).style.getPropertyValue('display').should.equal('');
|
|
364
|
+
cronapi.screen.hideComponent('cronapp');
|
|
365
|
+
$("#cronapp").get(0).style.getPropertyValue('display').should.equal('none');
|
|
366
|
+
cronapi.screen.showComponent('cronapp');
|
|
367
|
+
$("#cronapp").get(0).style.getPropertyValue('display').should.equal('block');
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('hideComponent', () => {
|
|
371
|
+
document.body.innerHTML = '<div id="cronapp">Low Code</div>';
|
|
372
|
+
$("#cronapp").get(0).style.getPropertyValue('display').should.equal('');
|
|
373
|
+
cronapi.screen.showComponent('cronapp');
|
|
374
|
+
$("#cronapp").get(0).style.getPropertyValue('display').should.equal('block');
|
|
375
|
+
cronapi.screen.hideComponent('cronapp');
|
|
376
|
+
$("#cronapp").get(0).style.getPropertyValue('display').should.equal('none');
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('disableComponent', () => {
|
|
380
|
+
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('enableComponent', () => {
|
|
384
|
+
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('focusComponent', () => {
|
|
388
|
+
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('changeAttrValue', () => {
|
|
392
|
+
document.body.innerHTML = '<img id="cronapp" width="300" height="300">';
|
|
393
|
+
cronapi.screen.changeAttrValue('cronapp', 'width', 500);
|
|
394
|
+
$('#cronapp').attr('width').should.equal('500');
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it('changeContent', () => {
|
|
398
|
+
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it('logout', () => {
|
|
402
|
+
cronapi.$scope['logout'] = jest.fn();
|
|
403
|
+
cronapi.screen.logout.bind(window)();
|
|
404
|
+
expect(cronapi.$scope.logout).toHaveBeenCalledTimes(1);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it('refreshDatasource', () => {
|
|
408
|
+
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it('loadMore', () => {
|
|
412
|
+
cronapi.screen.loadMore(dataSource);
|
|
413
|
+
expect(dataSource.nextPage).toHaveBeenCalledTimes(1);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it('hasNextPage', () => {
|
|
417
|
+
cronapi.screen.hasNextPage(dataSource).should.equal(true);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('load', () => {
|
|
421
|
+
cronapi.screen.load(dataSource);
|
|
422
|
+
expect(dataSource.fetch).toHaveBeenCalledTimes(1);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
describe('Test suit for category text from Cronapi.js',
|
|
3
|
+
function() {
|
|
4
|
+
const ch = require('chai');
|
|
5
|
+
let {window} = require('../../../../../cronapi');
|
|
6
|
+
ch.should();
|
|
7
|
+
const cronapi = window["cronapi"];
|
|
8
|
+
|
|
9
|
+
it('prompt', function() {
|
|
10
|
+
let value = cronapi.text.prompt.bind(window)('abc');
|
|
11
|
+
(value === null).should.equal(true);
|
|
12
|
+
|
|
13
|
+
value = cronapi.text.prompt.bind(window)(123);
|
|
14
|
+
(value === null).should.equal(true);
|
|
15
|
+
|
|
16
|
+
value = cronapi.text.prompt.bind(window)(null);
|
|
17
|
+
(value === null).should.equal(true);
|
|
18
|
+
|
|
19
|
+
value = cronapi.text.prompt.bind(window)(true);
|
|
20
|
+
(value === null).should.equal(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('newline', function() {
|
|
24
|
+
let value = cronapi.text.newline.bind(window)();
|
|
25
|
+
value.should.equal('\n');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('replaceAll', function() {
|
|
29
|
+
let value = cronapi.text.replaceAll.bind(window)(null, 'n', '-', 'c');
|
|
30
|
+
(value === null).should.equal(true);
|
|
31
|
+
|
|
32
|
+
value = cronapi.text.replaceAll.bind(window)('banana', null, '-', 'c');
|
|
33
|
+
(value === null).should.equal(true);
|
|
34
|
+
|
|
35
|
+
// Erro - Quando o typeReplace é passado como null, ocorre SyntaxError
|
|
36
|
+
// ao instanciar um RegExp com flag nula
|
|
37
|
+
// value = cronapi.text.replaceAll.bind(window)('banana', 'n', null, 'c');
|
|
38
|
+
// (value === null).should.equal(true);
|
|
39
|
+
|
|
40
|
+
value = cronapi.text.replaceAll.bind(window)('banana', 'n', '-', null);
|
|
41
|
+
(value === null).should.equal(true);
|
|
42
|
+
|
|
43
|
+
value = cronapi.text.replaceAll.bind(window)('banana', 'n', 'i', 'c');
|
|
44
|
+
value.should.equal('bacana');
|
|
45
|
+
|
|
46
|
+
// Erro - Quando o typeReplace é passado como '-', é dispara
|
|
47
|
+
// a função mais interna replace em vez de replaceAll
|
|
48
|
+
value = cronapi.text.replaceAll.bind(window)('banana', 'n', '-', 'c');
|
|
49
|
+
value.should.equal('bacaca');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('formatTextWithReplacement', function() {
|
|
53
|
+
let value = cronapi.text.formatTextWithReplacement.bind(window)("Hoje é {0} do mês {1} e do ano {2}", "31", "12", "2050");
|
|
54
|
+
value.should.equal("Hoje é 31 do mês 12 e do ano 2050");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
describe('Test suit for category Util from Cronapi.js', function() {
|
|
4
|
+
|
|
5
|
+
const chai = require('chai');
|
|
6
|
+
let {window} = require('../../../../../cronapi');
|
|
7
|
+
const cronapi = window["cronapi"];
|
|
8
|
+
chai.should();
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
it('createPromise', function() {
|
|
12
|
+
let value = cronapi.util.createPromise();
|
|
13
|
+
(typeof value.then).should.equal('function');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('handleValueToPromise ', function() {
|
|
17
|
+
const promise = cronapi.util.createPromise();
|
|
18
|
+
let result;
|
|
19
|
+
promise.__functionToResolve = (value)=> result = value;
|
|
20
|
+
promise.__functionToReject = (value)=> result = value;
|
|
21
|
+
|
|
22
|
+
cronapi.util.handleValueToPromise( 'resolve', promise , "100");
|
|
23
|
+
result.should.equal("100");
|
|
24
|
+
|
|
25
|
+
cronapi.util.handleValueToPromise( 'reject', promise , "0");
|
|
26
|
+
result.should.equal("0");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
describe('Test suit for category xml from Cronapi.js', function() {
|
|
2
|
+
const ch = require('chai');
|
|
3
|
+
ch.should();
|
|
4
|
+
|
|
5
|
+
const $ = require('jquery');
|
|
6
|
+
|
|
7
|
+
let {window} = require('../../../../../cronapi');
|
|
8
|
+
const cronapi = window["cronapi"];
|
|
9
|
+
|
|
10
|
+
window.$ = $;
|
|
11
|
+
|
|
12
|
+
it('newXMLEmpty', function() {
|
|
13
|
+
let value = cronapi.xml.newXMLEmpty.bind(window)();
|
|
14
|
+
(value === undefined || value === null || value === '').should.equal(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('newXMLEmptyWithRoot', function() {
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('newXMLElement', function() {
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('addXMLElement', function() {
|
|
24
|
+
let value = cronapi.xml.addXMLElement(null, $.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'));
|
|
25
|
+
value.should.eql(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('XMLHasRootElement', function() {
|
|
29
|
+
let value = cronapi.xml.XMLHasRootElement($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'));
|
|
30
|
+
value.should.eql(true);
|
|
31
|
+
|
|
32
|
+
value = cronapi.xml.XMLHasRootElement(null);
|
|
33
|
+
value.should.eql(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('XMLGetRootElement', function() {
|
|
37
|
+
let value = cronapi.xml.XMLGetRootElement($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'));
|
|
38
|
+
(value === undefined || value === null || value === '').should.equal(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('XMLDocumentToText', function() {
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('getChildren', function() {
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('setAttribute', function() {
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('getAttributeValue', function() {
|
|
51
|
+
let value = cronapi.xml.getAttributeValue(null, false);
|
|
52
|
+
value.should.eql('');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('getParentNode', function() {
|
|
56
|
+
let value = cronapi.xml.getParentNode($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'));
|
|
57
|
+
(value === undefined || value === null || value === '').should.equal(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('setElementContent', function() {
|
|
61
|
+
let value = cronapi.xml.setElementContent($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'), $.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'));
|
|
62
|
+
(value === undefined || value === null || value === '').should.equal(true);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('getElementContent', function() {
|
|
66
|
+
let value = cronapi.xml.getElementContent($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'));
|
|
67
|
+
(value === undefined || value === null || value === '').should.equal(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('removeElement', function() {
|
|
71
|
+
let value = cronapi.xml.removeElement($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'), true);
|
|
72
|
+
(value === undefined || value === null || value === '').should.equal(true);
|
|
73
|
+
|
|
74
|
+
value = cronapi.xml.removeElement($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'), false);
|
|
75
|
+
(value === undefined || value === null || value === '').should.equal(true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('getElementName', function() {
|
|
79
|
+
let value = cronapi.xml.getElementName($.parseXML('<?xml version="1.0" encoding="UTF-8"?><root></root>'));
|
|
80
|
+
(value === undefined || value === null || value === '').should.equal(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('renameElement', function() {
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
});
|