@itee/tasks 1.4.4 → 1.4.5

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 (61) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/package.json +3 -3
  3. package/sources/utils/testing.js +1 -1
  4. package/docs/-_utils.mjs.html +0 -898
  5. package/docs/cleans_clean.task.mjs.html +0 -238
  6. package/docs/fonts/glyphicons-halflings-regular.eot +0 -0
  7. package/docs/fonts/glyphicons-halflings-regular.svg +0 -288
  8. package/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
  9. package/docs/fonts/glyphicons-halflings-regular.woff +0 -0
  10. package/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
  11. package/docs/global.html +0 -2200
  12. package/docs/helps_help.task.mjs.html +0 -326
  13. package/docs/img/glyphicons-halflings-white.png +0 -0
  14. package/docs/img/glyphicons-halflings.png +0 -0
  15. package/docs/index.html +0 -228
  16. package/docs/lints_lint.task.mjs.html +0 -255
  17. package/docs/patches_patch.task.mjs.html +0 -252
  18. package/docs/quicksearch.html +0 -31
  19. package/docs/releases_release.task.mjs.html +0 -238
  20. package/docs/scripts/docstrap.lib.js +0 -11
  21. package/docs/scripts/fulltext-search-ui.js +0 -89
  22. package/docs/scripts/fulltext-search.js +0 -36
  23. package/docs/scripts/lunr.min.js +0 -6
  24. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  25. package/docs/scripts/prettify/jquery.min.js +0 -6
  26. package/docs/scripts/prettify/lang-css.js +0 -21
  27. package/docs/scripts/prettify/prettify.js +0 -496
  28. package/docs/scripts/sunlight.js +0 -1157
  29. package/docs/scripts/toc.js +0 -203
  30. package/docs/styles/darkstrap.css +0 -960
  31. package/docs/styles/prettify-tomorrow.css +0 -132
  32. package/docs/styles/site.cerulean.css +0 -7008
  33. package/docs/styles/site.cosmo.css +0 -7061
  34. package/docs/styles/site.cyborg.css +0 -7048
  35. package/docs/styles/site.darkly.css +0 -7171
  36. package/docs/styles/site.darkstrap.css +0 -5638
  37. package/docs/styles/site.dibs-bootstrap.css +0 -5899
  38. package/docs/styles/site.flatly.css +0 -7147
  39. package/docs/styles/site.journal.css +0 -6973
  40. package/docs/styles/site.lumen.css +0 -7298
  41. package/docs/styles/site.paper.css +0 -7623
  42. package/docs/styles/site.readable.css +0 -6997
  43. package/docs/styles/site.sandstone.css +0 -7035
  44. package/docs/styles/site.simplex.css +0 -7023
  45. package/docs/styles/site.slate.css +0 -7343
  46. package/docs/styles/site.spacelab.css +0 -7055
  47. package/docs/styles/site.superhero.css +0 -7131
  48. package/docs/styles/site.united.css +0 -6895
  49. package/docs/styles/site.yeti.css +0 -7195
  50. package/docs/styles/sunlight.dark.css +0 -345
  51. package/docs/styles/sunlight.default.css +0 -344
  52. package/docs/tests_benchmarks_compute-benchmarks.task.mjs.html +0 -438
  53. package/docs/tests_benchmarks_run-benchmarks-for-backend.task.mjs.html +0 -251
  54. package/docs/tests_benchmarks_run-benchmarks-for-frontend.task.mjs.html +0 -252
  55. package/docs/tests_bundlings_check-bundling-from-esm-files-direct.task.mjs.html +0 -288
  56. package/docs/tests_bundlings_check-bundling.task.mjs.html +0 -231
  57. package/docs/tests_run-tests.task.mjs.html +0 -228
  58. package/docs/tests_units_compute-unit-tests.task.mjs.html +0 -758
  59. package/docs/tests_units_run-unit-tests-for-backend.task.mjs.html +0 -256
  60. package/docs/tests_units_run-unit-tests-for-frontend.task.mjs.html +0 -252
  61. package/docs/utils_texts.mjs.html +0 -328
@@ -1,758 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html lang="en">
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width">
7
- <title>Itee Tasks v1.4.3 Source: tests/units/compute-unit-tests.task.mjs</title>
8
-
9
- <!--[if lt IE 9]>
10
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
- <![endif]-->
12
- <link type="text/css" rel="stylesheet" href="styles/sunlight.dark.css">
13
-
14
- <link type="text/css" rel="stylesheet" href="styles/site.cyborg.css">
15
-
16
- </head>
17
-
18
- <body>
19
-
20
- <div class="navbar navbar-default navbar-fixed-top ">
21
- <div class="container">
22
- <div class="navbar-header">
23
- <a class="navbar-brand" href="index.html">Itee Tasks v1.4.3</a>
24
- <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
25
- <span class="icon-bar"></span>
26
- <span class="icon-bar"></span>
27
- <span class="icon-bar"></span>
28
- </button>
29
- </div>
30
- <div class="navbar-collapse collapse" id="topNavigation">
31
- <ul class="nav navbar-nav">
32
-
33
- <li class="dropdown">
34
- <a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
35
- <ul class="dropdown-menu inline">
36
- <li><a href="global.html#alignTextCenter">alignTextCenter</a></li><li><a href="global.html#alignTextLeft">alignTextLeft</a></li><li><a href="global.html#alignTextRight">alignTextRight</a></li><li><a href="global.html#checkBundlingFromEsmFilesDirectTask">checkBundlingFromEsmFilesDirectTask</a></li><li><a href="global.html#checkBundlingTask">checkBundlingTask</a></li><li><a href="global.html#computeBenchmarksTask">computeBenchmarksTask</a></li><li><a href="global.html#computeUnitTestsTask">computeUnitTestsTask</a></li><li><a href="global.html#npmrunclean">npm run clean</a></li><li><a href="global.html#npmrunhelpdefault">npm run help ( default )</a></li><li><a href="global.html#npmrunlint">npm run lint</a></li><li><a href="global.html#npmrunpatch">npm run patch</a></li><li><a href="global.html#npmrunrelease">npm run release</a></li><li><a href="global.html#npmruntest">npm run test</a></li><li><a href="global.html#runBenchmarksForBackendTask">runBenchmarksForBackendTask</a></li><li><a href="global.html#runBenchmarksForFrontendTask">runBenchmarksForFrontendTask</a></li><li><a href="global.html#runUnitTestsForBackendTask">runUnitTestsForBackendTask</a></li><li><a href="global.html#runUnitTestsForFrontendTask">runUnitTestsForFrontendTask</a></li><li><a href="global.html#toCamelCase">toCamelCase</a></li>
37
- </ul>
38
- </li>
39
-
40
- </ul>
41
-
42
- <div class="col-sm-3 col-md-3">
43
- <form class="navbar-form" role="search">
44
- <div class="input-group">
45
- <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
46
- <div class="input-group-btn">
47
- <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
48
- </div>
49
- </div>
50
- </form>
51
- </div>
52
-
53
- </div>
54
-
55
- </div>
56
- </div>
57
-
58
-
59
- <div class="container" id="toc-content">
60
- <div class="row">
61
-
62
-
63
- <div class="col-md-12">
64
-
65
- <div id="main">
66
-
67
-
68
- <h1 class="page-title">Source: tests/units/compute-unit-tests.task.mjs</h1>
69
-
70
- <section>
71
- <article>
72
- <pre
73
- class="sunlight-highlight-javascript linenums">import { isNotEmptyArray } from 'itee-validators'
74
- import childProcess from 'node:child_process'
75
- import {
76
- basename,
77
- dirname,
78
- extname,
79
- join,
80
- relative
81
- } from 'node:path'
82
- import {
83
- red,
84
- yellow
85
- } from '../../utils/colors.mjs'
86
- import {
87
- createDirectoryIfNotExist,
88
- createFile,
89
- getJavascriptSourceFiles
90
- } from '../../utils/files.mjs'
91
- import {
92
- log,
93
- logLoadingTask
94
- } from '../../utils/loggings.mjs'
95
- import {
96
- getPrettyPackageName,
97
- getUnscopedPackageName,
98
- iteePackageSourcesDirectory,
99
- packageNodeModulesDirectory,
100
- packageSourcesDirectory,
101
- packageTestsUnitsDirectory
102
- } from '../../utils/packages.mjs'
103
- import { getTaskConfigurationFor } from '../../utils/tasks.mjs'
104
- import {
105
- Indenter,
106
- toCamelCase
107
- } from '../../utils/texts.mjs'
108
-
109
- logLoadingTask( import.meta.filename )
110
-
111
- /**
112
- * @description Will generate unit test files from source code using type inference from comments
113
- */
114
- const computeUnitTestsTask = async ( done ) => {
115
-
116
- createDirectoryIfNotExist( packageTestsUnitsDirectory )
117
-
118
- const filePathsToIgnore = await getTaskConfigurationFor( import.meta.filename )
119
- const sourceFiles = getJavascriptSourceFiles( filePathsToIgnore )
120
-
121
- const unitsImportMap = []
122
- for ( let sourceFile of sourceFiles ) {
123
-
124
- const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
125
- const specificDir = dirname( specificFilePath )
126
-
127
- const fileName = basename( sourceFile, extname( sourceFile ) )
128
- const camelCaseFileName = toCamelCase( fileName )
129
- const unitFileName = `${ camelCaseFileName }.unit.mjs`
130
- const unitDirPath = join( packageTestsUnitsDirectory, specificDir )
131
- const unitFilePath = join( unitDirPath, unitFileName )
132
-
133
- const nsName = `${ camelCaseFileName }Namespace`
134
- const unitName = `${ camelCaseFileName }Units`
135
- const importDirPath = relative( unitDirPath, packageSourcesDirectory )
136
- const importFilePath = join( importDirPath, specificFilePath ).replace( /\\/g, '/' )
137
-
138
- try {
139
-
140
- const jsdocPath = join( packageNodeModulesDirectory, '/jsdoc/jsdoc.js' )
141
- const jsdocOutput = childProcess.execFileSync( 'node', [ jsdocPath, '--explain', sourceFile ] ).toString()
142
-
143
- if ( jsdocOutput.includes( 'There are no input files to process' ) ) {
144
- log( 'Error ', red( `${ sourceFile }, no input files to process` ) )
145
- continue
146
- }
147
-
148
- const classNames = []
149
- const usedLongnames = []
150
- const jsonData = JSON.parse( jsdocOutput ).filter( data => {
151
-
152
- const longName = data.longname
153
-
154
- const kind = data.kind
155
- if ( kind !== 'function' ) {
156
- if ( kind === 'class' &amp;&amp; !classNames.includes( longName ) ) {
157
- classNames.push( longName )
158
- }
159
- return false
160
- }
161
-
162
- const undocumented = data.undocumented
163
- if ( undocumented ) {
164
- return false
165
- }
166
-
167
- const scope = data.scope
168
- if ( ![ 'global', 'static' ].includes( scope ) ) {
169
- return false
170
- }
171
-
172
- if ( longName.includes( ' ' ) || longName.includes( '~' ) || usedLongnames.includes( longName ) ) {
173
- return false
174
- }
175
-
176
- for ( let className of classNames ) {
177
- if ( longName.includes( className ) ) {
178
- return false
179
- }
180
- }
181
-
182
- usedLongnames.push( longName )
183
-
184
- return true
185
-
186
- } )
187
-
188
- if ( jsonData.length === 0 ) {
189
- log( 'Ignoring', yellow( `${ sourceFile }, no usable exports found` ) )
190
- continue
191
- }
192
-
193
- let describes = ''
194
- const {
195
- I,
196
- I_,
197
- I__,
198
- I___,
199
- } = new Indenter( '\t', 3 )
200
-
201
- for ( let docData of jsonData ) {
202
-
203
- try {
204
-
205
- //check input parameters and types
206
- const docParameters = docData.params || []
207
- const parameters = []
208
- for ( let pIndex = 0 ; pIndex &lt; docParameters.length ; pIndex++ ) {
209
- const param = docParameters[ pIndex ]
210
- let paramName = param.name
211
- if ( !paramName ) {
212
- paramName = `param${ pIndex }`
213
- log( yellow( `Missing parameter name for [${ docData.longname }]. Defaulting to [${ paramName }]` ) )
214
- }
215
-
216
- const paramType = param.type
217
- if ( !paramType ) {
218
- throw new ReferenceError( `Missing parameter type. Unable to create unit test for [${ docData.longname }] !` )
219
- }
220
-
221
- const parameter = {
222
- name: paramName,
223
- types: []
224
- }
225
-
226
- const paramTypeNames = paramType.names
227
- for ( let type of paramTypeNames ) {
228
- parameter.types.push( type )
229
- }
230
-
231
- parameters.push( parameter )
232
- }
233
-
234
- // Check returns types
235
- const docReturns = docData.returns || []
236
- const returns = []
237
- for ( let docReturn of docReturns ) {
238
- const returnType = docReturn.type
239
- if ( !returnType ) {
240
- throw new ReferenceError( `Missing return type for [${ docData.longname }]. Ignore current target !` )
241
- }
242
- returns.push( ...returnType.names )
243
- }
244
-
245
- // Todo check throws
246
-
247
- // Get user define rules
248
- // const rules = []
249
-
250
-
251
- // Infer basic rules
252
- const baseIndent = 2
253
- let its = ''
254
-
255
- if ( parameters.length === 0 ) {
256
-
257
- if ( returns.length === 0 ) {
258
-
259
- const result = `${ I._( baseIndent + 1 ) }const result = ${ nsName }.${ docData.name }()` + '\n'
260
- const expect = `${ I._( baseIndent + 1 ) }expect(result).to.be.a('undefined')` + '\n'
261
-
262
- its += '' +
263
- `${ I._( baseIndent ) }it( 'should return undefined value on call', async function () {` + '\n' +
264
- '\n' +
265
- `${ result }` +
266
- `${ expect }` +
267
- '\n' +
268
- `${ I._( baseIndent ) }} )` + '\n'
269
-
270
- } else if ( returns.length === 1 ) {
271
-
272
- const firstReturnType = returns[ 0 ]
273
- const lowerName = firstReturnType.toLowerCase()
274
-
275
- const result = `${ I._( baseIndent + 1 ) }const result = ${ nsName }.${ docData.name }()` + '\n'
276
-
277
- let expect = ''
278
- if ( lowerName.startsWith( 'array' ) ) {
279
- //todo array of...
280
- expect += `${ I._( baseIndent + 1 ) }expect(result).to.be.a('array')` + '\n'
281
- } else {
282
- expect += `${ I._( baseIndent + 1 ) }expect(result).to.be.a('${ lowerName }')` + '\n'
283
- }
284
-
285
- its += '' +
286
- `${ I._( baseIndent ) }it( 'should return value of type ${ lowerName }', async function() {` + '\n' +
287
- '\n' +
288
- `${ result }` +
289
- `${ expect }` +
290
- '\n' +
291
- `${ I._( baseIndent ) }} )` + '\n'
292
-
293
- } else {
294
-
295
- const result = `${ I._( baseIndent + 1 ) }const result = ${ nsName }.${ docData.name }()` + '\n'
296
-
297
- let returnTypesLabel = []
298
- let oneOf = []
299
- for ( let returnType of returns ) {
300
-
301
- const lowerName = returnType.toLowerCase()
302
- returnTypesLabel.push( lowerName )
303
-
304
- if ( lowerName.startsWith( 'array' ) ) {
305
- //todo array of...
306
- oneOf.push( 'array' )
307
- } else {
308
- oneOf.push( `'${ lowerName }'` )
309
- }
310
-
311
- }
312
-
313
- const underlyingType = `${ I._( baseIndent + 1 ) }const resultType = (result === null) ? 'null' : typeof result` + '\n'
314
- const expect = `${ I._( baseIndent + 1 ) }expect(resultType).to.be.oneOf([${ oneOf.join( ',' ) }])` + '\n'
315
-
316
- its += '' +
317
- `${ I._( baseIndent ) }it( 'should return value where type is ${ returnTypesLabel.join( ' or ' ) }', async function() {` + '\n' +
318
- '\n' +
319
- `${ result }` +
320
- `${ underlyingType }` +
321
- `${ expect }` +
322
- '\n' +
323
- `${ I._( baseIndent ) }} )` + '\n'
324
-
325
- }
326
-
327
- } else {
328
-
329
- if ( returns.length === 0 ) {
330
-
331
- let itDeclaration = []
332
- let index = 0
333
- let indent = baseIndent + 1
334
- let localIndent = indent
335
- let dataSets = ''
336
- let forLoopOpens = ''
337
- let forLoopCloses = ''
338
- let args = []
339
- for ( let parameter of parameters ) {
340
-
341
- const parameterType = parameter.types[ 0 ]
342
- itDeclaration.push( `${ parameter.name } is of type ${ parameterType }` )
343
-
344
- dataSets += `${ I._( indent ) }const dataSet${ index } = _dataMap[ '${ parameterType }s' ]` + '\n'
345
- // dataSets += `${ I._( indent ) }const dataSet${ index } = this._dataMap[ '${ parameterType }s' ]` + '\n'
346
- forLoopOpens += '' + '\n' +
347
- `${ I._( localIndent ) }for ( let key${ index } in dataSet${ index } ) {` + '\n' +
348
- `${ I._( localIndent + 1 ) }const dataSetValue${ index } = dataSet${ index }[ key${ index } ]` + '\n'
349
-
350
- args.push( `dataSetValue${ index }` )
351
-
352
- forLoopCloses = `${ I._( localIndent ) }}` + '\n' + `${ forLoopCloses }`
353
-
354
- index++
355
- localIndent++
356
- }
357
-
358
- const result = `${ I._( localIndent ) }const result = ${ nsName }.${ docData.name }( ${ args.join( ', ' ) } )` + '\n'
359
- const expect = `${ I._( localIndent ) }expect(result).to.be.a('undefined')` + '\n'
360
-
361
- const param = '' +
362
- `${ dataSets }` +
363
- `${ forLoopOpens }` +
364
- `${ result }` +
365
- `${ expect }` +
366
- `${ forLoopCloses }`
367
-
368
- its += '' +
369
- `${ I._( baseIndent ) }it( 'should return undefined value when ${ itDeclaration.join( ' and ' ) }', async function() {` + '\n' +
370
- '\n' +
371
- `${ param }` +
372
- '\n' +
373
- `${ I._( baseIndent ) }} )` + '\n'
374
-
375
- } else if ( returns.length === 1 ) {
376
-
377
- const firstReturnType = returns[ 0 ]
378
- const lowerName = firstReturnType.toLowerCase()
379
-
380
- let itDeclaration = []
381
- let index = 0
382
- let indent = baseIndent + 1
383
- let localIndent = indent
384
- let dataSets = ''
385
- let forLoopOpens = ''
386
- let forLoopCloses = ''
387
- let args = []
388
- for ( let parameter of parameters ) {
389
-
390
- const parameterType = parameter.types[ 0 ]
391
- const isAnyType = ( parameterType === '*' || parameterType.toLowerCase() === 'any' )
392
- const declaration = ( isAnyType )
393
- ? `${ parameter.name } is of any type`
394
- : `${ parameter.name } is of type ${ parameterType }`
395
- itDeclaration.push( declaration )
396
-
397
- if ( isAnyType ) {
398
-
399
- dataSets += `${ I._( indent ) }const dataMap${ index } = _dataMap` + '\n' +
400
- // dataSets += `${ I._( indent ) }const dataMap${ index } = this._dataMap` + '\n' +
401
- `${ I._( localIndent ) }for ( let dataSetKey${ index } in dataMap${ index } ) {` + '\n'
402
-
403
- localIndent++
404
- dataSets += `${ I._( indent + 1 ) }const dataSet${ index } = dataMap${ index }[ dataSetKey${ index } ]` + '\n'
405
- forLoopOpens += '' + '\n' +
406
- `${ I._( localIndent ) }for ( let key${ index } in dataSet${ index } ) {` + '\n' +
407
- `${ I._( localIndent + 1 ) }const dataSetValue${ index } = dataSet${ index }[ key${ index } ]` + '\n'
408
-
409
- args.push( `dataSetValue${ index }` )
410
-
411
- forLoopCloses = `${ I._( localIndent ) }}` + '\n' +
412
- `${ I._( localIndent - 1 ) }}` + '\n' +
413
- `${ forLoopCloses }`
414
-
415
- } else {
416
-
417
- dataSets += `${ I._( indent ) }const dataSet${ index } = _dataMap[ '${ parameterType }s' ]` + '\n'
418
- // dataSets += `${ I._( indent ) }const dataSet${ index } = this._dataMap[ '${ parameterType }s' ]` + '\n'
419
- forLoopOpens += '' + '\n' +
420
- `${ I._( localIndent ) }for ( let key${ index } in dataSet${ index } ) {` + '\n' +
421
- `${ I._( localIndent + 1 ) }const dataSetValue${ index } = dataSet${ index }[ key${ index } ]` + '\n'
422
-
423
- args.push( `dataSetValue${ index }` )
424
-
425
- forLoopCloses = `${ I._( localIndent ) }}` + '\n' + `${ forLoopCloses }`
426
-
427
- }
428
-
429
-
430
- index++
431
- localIndent++
432
- }
433
-
434
- const result = `${ I._( localIndent ) }const result = ${ nsName }.${ docData.name }( ${ args.join( ', ' ) } )` + '\n'
435
-
436
- let expect = ''
437
- if ( lowerName.startsWith( 'array' ) ) {
438
- expect = `${ I._( localIndent ) }expect(result).to.be.a('array')` + '\n'
439
- //todo array of...
440
- } else {
441
- expect = `${ I._( localIndent ) }expect(result).to.be.a('${ lowerName }')` + '\n'
442
- }
443
-
444
- const param = '' +
445
- `${ dataSets }` +
446
- `${ forLoopOpens }` +
447
- `${ result }` +
448
- `${ expect }` +
449
- `${ forLoopCloses }`
450
-
451
- its += '' +
452
- `${ I._( baseIndent ) }it( 'should return value of type ${ lowerName } when ${ itDeclaration.join( ' and ' ) }', async function() {` + '\n' +
453
- '\n' +
454
- `${ param }` +
455
- '\n' +
456
- `${ I._( baseIndent ) }} )` + '\n'
457
-
458
- } else {
459
-
460
- let itDeclaration = []
461
- let index = 0
462
- let indent = baseIndent + 1
463
- let localIndent = indent
464
- let dataSets = ''
465
- let forLoopOpens = ''
466
- let forLoopCloses = ''
467
- let args = []
468
- for ( let parameter of parameters ) {
469
-
470
- const parameterType = parameter.types[ 0 ]
471
- itDeclaration.push( `${ parameter.name } is of type ${ parameterType }` )
472
-
473
- dataSets += `${ I._( localIndent ) }const dataSet${ index } = _dataMap[ '${ parameterType }s' ]` + '\n'
474
- // dataSets += `${ I._( indent ) }const dataSet${ index } = this._dataMap[ '${ parameterType }s' ]` + '\n'
475
- forLoopOpens += '' + '\n' +
476
- `${ I._( localIndent ) }for ( let key${ index } in dataSet${ index } ) {` + '\n' +
477
- `${ I._( localIndent + 1 ) }const dataSetValue${ index } = dataSet${ index }[ key${ index } ]` + '\n'
478
-
479
- args.push( `dataSetValue${ index }` )
480
-
481
- forLoopCloses = `${ I._( localIndent ) }}` + '\n' + `${ forLoopCloses }`
482
-
483
- index++
484
- localIndent++
485
- }
486
-
487
- const result = `${ I._( localIndent + 1 ) }const result = ${ nsName }.${ docData.name }( ${ args.join( ', ' ) } )` + '\n'
488
-
489
- let returnTypesLabel = []
490
- let oneOf = []
491
- for ( let returnType of returns ) {
492
-
493
- const lowerName = returnType.toLowerCase()
494
- returnTypesLabel.push( lowerName )
495
-
496
- if ( lowerName.startsWith( 'array' ) ) {
497
- //todo array of...
498
- oneOf.push( 'array' )
499
- } else {
500
- oneOf.push( `'${ lowerName }'` )
501
- }
502
-
503
- }
504
-
505
- const underlyingType = `${ I._( localIndent + 1 ) }const resultType = (result === null) ? 'null' : typeof result` + '\n'
506
- const expect = `${ I._( localIndent + 1 ) }expect(resultType).to.be.oneOf([${ oneOf.join( ',' ) }])` + '\n'
507
-
508
- const param = '' +
509
- `${ dataSets }` +
510
- `${ forLoopOpens }` +
511
- `${ result }` +
512
- `${ underlyingType }` +
513
- `${ expect }` +
514
- `${ forLoopCloses }`
515
-
516
- its += '' +
517
- `${ I._( baseIndent ) }it( 'should return value of type ${ returnTypesLabel.join( ' or ' ) } when ${ itDeclaration.join( ' and ' ) }', async function() {` + '\n' +
518
- '\n' +
519
- `${ param }` +
520
- '\n' +
521
- `${ I._( baseIndent ) }} )` + '\n'
522
-
523
- }
524
-
525
- }
526
-
527
- describes += '' +
528
- `${ I_ }describe( '${ docData.name }()', function () {` + '\n' +
529
- '\n' +
530
- `${ I__ }it( 'should be bundlable', async function () {` + '\n' +
531
- '\n' +
532
- `${ I___ }expect(${ nsName }.${ docData.name }).to.exist` + '\n' +
533
- '\n' +
534
- `${ I__ }} )` + '\n' +
535
- '\n' +
536
- `${ its }` +
537
- '\n' +
538
- `${ I_ }} )` + '\n' +
539
- '\n'
540
-
541
- } catch ( error ) {
542
-
543
- log( red( error.message ) )
544
-
545
- }
546
-
547
- }
548
-
549
- const wrapperDirPath = relative( unitDirPath, iteePackageSourcesDirectory )
550
- const importTestingFilePath = join( wrapperDirPath, 'utils', 'testing.js' )
551
-
552
- const template = '' +
553
- `import { expect } from 'chai'` + '\n' +
554
- `import { getTestingPackage } from '${ importTestingFilePath }'` + '\n' +
555
- // `import { Testing } from 'itee-utils/sources/testings/benchmarks.js'` + '\n' +
556
- `import * as ${ nsName } from '${ importFilePath }'` + '\n' +
557
- '\n' +
558
- `const Testing = await getTestingPackage()` + '\n' +
559
- '\n' +
560
- `describe( '${ unitName }', function () {` + '\n' +
561
- '\n' +
562
- `${ I_ }let _dataMap` + '\n' +
563
- `${ I_ }before( function() {` + '\n' +
564
- `${ I__ }_dataMap = Testing.createDataMap()` + '\n' +
565
- `${ I_ }} )` + '\n' +
566
- '\n' +
567
- `${ describes }` +
568
- '' +
569
- `} )` + '\n'
570
-
571
- const importUnitFilePath = relative( packageTestsUnitsDirectory, unitFilePath )
572
- unitsImportMap.push( {
573
- exportName: unitName,
574
- path: importUnitFilePath.replace( /\\/g, '/' )
575
- } )
576
-
577
- createDirectoryIfNotExist( unitDirPath )
578
- createFile( unitFilePath, template )
579
-
580
- } catch ( error ) {
581
-
582
- log( red( error.message ) )
583
-
584
- }
585
-
586
- }
587
-
588
- // If some tests to import generate global units file
589
- let unitsTemplate
590
- if ( isNotEmptyArray( unitsImportMap ) ) {
591
-
592
- let computedImports = []
593
- for ( let entry of unitsImportMap ) {
594
- // computedImports.push(`import { ${ entry.exportName } } from './${ entry.path }'`)
595
- computedImports.push( `export * from './${ entry.path }'` )
596
- }
597
-
598
- unitsTemplate = computedImports.join( '\n' )
599
-
600
- } else {
601
-
602
- log( 'Warning ', yellow( 'No tests were generated. Create fallback global root import file.' ) )
603
- const defaultUnitsDir = join( packageTestsUnitsDirectory, 'default' )
604
- const defaultUnitsPath = join( defaultUnitsDir, 'default.unit.mjs' )
605
-
606
- createDirectoryIfNotExist( defaultUnitsDir )
607
- createFile( defaultUnitsPath, '// Avoid web test runner crash on empty benches' )
608
-
609
- const prettyPackageName = getPrettyPackageName( '#' )
610
- unitsTemplate = `describe( '${ prettyPackageName }', () => {} )` + '\n'
611
-
612
- }
613
-
614
- const unitsFilePath = join( packageTestsUnitsDirectory, `${ getUnscopedPackageName() }.units.mjs` )
615
- createFile( unitsFilePath, unitsTemplate )
616
-
617
- done()
618
-
619
- }
620
- computeUnitTestsTask.displayName = basename( import.meta.filename, '.task.mjs' )
621
- computeUnitTestsTask.description = 'Will generate unit test files from source code using type inference from comments'
622
- computeUnitTestsTask.flags = null
623
-
624
- export { computeUnitTestsTask }</pre>
625
- </article>
626
- </section>
627
-
628
-
629
-
630
-
631
-
632
- </div>
633
- </div>
634
-
635
- <div class="clearfix"></div>
636
-
637
-
638
-
639
- </div>
640
- </div>
641
-
642
-
643
- <div class="modal fade" id="searchResults">
644
- <div class="modal-dialog">
645
- <div class="modal-content">
646
- <div class="modal-header">
647
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
648
- <h4 class="modal-title">Search results</h4>
649
- </div>
650
- <div class="modal-body"></div>
651
- <div class="modal-footer">
652
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
653
- </div>
654
- </div><!-- /.modal-content -->
655
- </div><!-- /.modal-dialog -->
656
- </div>
657
-
658
-
659
- <footer>
660
-
661
-
662
- <span class="copyright">
663
- Copyright 2015-Present <a href="https://github.com/Itee">Itee (Tristan Valcke)</a>
664
- </span>
665
-
666
- <span class="jsdoc-message">
667
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a>
668
-
669
- using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
670
- </span>
671
- </footer>
672
-
673
- <script src="scripts/docstrap.lib.js"></script>
674
- <script src="scripts/toc.js"></script>
675
-
676
- <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
677
-
678
-
679
- <script>
680
- $( function () {
681
- $( "[id*='$']" ).each( function () {
682
- var $this = $( this );
683
-
684
- $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
685
- } );
686
-
687
- $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
688
- var $this = $( this );
689
-
690
- var example = $this.find( "code" );
691
- exampleText = example.html();
692
- var lang = /{@lang (.*?)}/.exec( exampleText );
693
- if ( lang && lang[1] ) {
694
- exampleText = exampleText.replace( lang[0], "" );
695
- example.html( exampleText );
696
- lang = lang[1];
697
- } else {
698
- var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
699
- lang = langClassMatch ? langClassMatch[1] : "javascript";
700
- }
701
-
702
- if ( lang ) {
703
-
704
- $this
705
- .addClass( "sunlight-highlight-" + lang )
706
- .addClass( "linenums" )
707
- .html( example.html() );
708
-
709
- }
710
- } );
711
-
712
- Sunlight.highlightAll( {
713
- lineNumbers : true,
714
- showMenu : true,
715
- enableDoclinks : true
716
- } );
717
-
718
- $.catchAnchorLinks( {
719
- navbarOffset: 10
720
- } );
721
- $( "#toc" ).toc( {
722
- anchorName : function ( i, heading, prefix ) {
723
- return $( heading ).attr( "id" ) || ( prefix + i );
724
- },
725
- selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
726
- showAndHide : false,
727
- smoothScrolling: true
728
- } );
729
-
730
- $( "#main span[id^='toc']" ).addClass( "toc-shim" );
731
- $( '.dropdown-toggle' ).dropdown();
732
-
733
- $( "table" ).each( function () {
734
- var $this = $( this );
735
- $this.addClass('table');
736
- } );
737
-
738
- } );
739
- </script>
740
-
741
-
742
-
743
- <!--Navigation and Symbol Display-->
744
-
745
-
746
- <!--Google Analytics-->
747
-
748
-
749
-
750
- <script type="text/javascript">
751
- $(document).ready(function() {
752
- SearcherDisplay.init();
753
- });
754
- </script>
755
-
756
-
757
- </body>
758
- </html>