@lumjs/tests 1.0.0 → 1.1.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.
- package/CHANGELOG.md +18 -2
- package/{src → lib}/functional.js +4 -6
- package/{src → lib}/harness.js +0 -0
- package/lib/index.js +23 -0
- package/{src → lib}/log.js +0 -0
- package/{src → lib}/test.js +48 -7
- package/package.json +2 -2
- package/test/basics.js +1 -1
- package/test/dies.js +1 -1
- package/test/functional_basics.js +1 -1
- package/test/functional_dies.js +1 -1
- package/index.js +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -6,11 +6,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.1.0] - 2022-07-08
|
|
10
|
+
### Fixed
|
|
11
|
+
- Changelog had wrong URLs.
|
|
12
|
+
### Changed
|
|
13
|
+
- Renamed `src` to `lib` like `@lumjs/core` did.
|
|
14
|
+
- Moved `index.js` into `lib` and updated `package.json` to reflect that.
|
|
15
|
+
- Updated all the tests to use the new paths.
|
|
16
|
+
- Changed `Test` constructor to support a bunch of options.
|
|
17
|
+
- `id` option will be used in the future.
|
|
18
|
+
- `plan` option replaces the old `plan` pararameter.
|
|
19
|
+
- `module` option will assign the test instance to `opts.module.exports`.
|
|
20
|
+
- `module` can also auto-generate an `id` if one was not passed.
|
|
21
|
+
- `moduleName` is used for the automatic `id` generation.
|
|
22
|
+
- Updated `functional()` and `new()` to pass their options to the constructor.
|
|
23
|
+
|
|
9
24
|
## [1.0.0] - 2022-06-22
|
|
10
25
|
### Added
|
|
11
26
|
- Ported from Lum.js v4 library set.
|
|
12
27
|
- Added a few more features from the PHP version.
|
|
13
28
|
|
|
14
|
-
[Unreleased]: https://github.com/supernovus/
|
|
15
|
-
[1.
|
|
29
|
+
[Unreleased]: https://github.com/supernovus/lum.tests.js/compare/v1.1.0...HEAD
|
|
30
|
+
[1.1.0]: https://github.com/supernovus/lum.tests.js/compare/v1.0.0...v1.1.0
|
|
31
|
+
[1.0.0]: https://github.com/supernovus/lum.tests.js/releases/tag/v1.0.0
|
|
16
32
|
|
|
@@ -51,17 +51,15 @@ const PROXY_METHODS =
|
|
|
51
51
|
* and a new set of wrapper functions for the test instance, you could
|
|
52
52
|
* create multiple sets of functional tests in their own private scopes.
|
|
53
53
|
* Not sure why you'd want to do that, but in case you do, there ya go.
|
|
54
|
+
*
|
|
55
|
+
* @param {object} [opts] Options to pass to the `Test` constructor.
|
|
54
56
|
*
|
|
55
57
|
* @returns {Functional}
|
|
56
58
|
*
|
|
57
59
|
*/
|
|
58
|
-
function functional(
|
|
60
|
+
function functional(opts={})
|
|
59
61
|
{
|
|
60
|
-
const test = new Test(
|
|
61
|
-
if (module)
|
|
62
|
-
{
|
|
63
|
-
module.exports = test;
|
|
64
|
-
}
|
|
62
|
+
const test = new Test(opts);
|
|
65
63
|
const functions = { test };
|
|
66
64
|
for (const meth of PROXY_METHODS)
|
|
67
65
|
{
|
package/{src → lib}/harness.js
RENAMED
|
File without changes
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Several test related classes.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const Test = require('./test');
|
|
6
|
+
|
|
7
|
+
module.exports.Test = Test;
|
|
8
|
+
module.exports.Harness = require('./harness');
|
|
9
|
+
|
|
10
|
+
// This one is not a class, but a special function.
|
|
11
|
+
module.exports.functional = require('./functional');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create a new Test instance.
|
|
15
|
+
*
|
|
16
|
+
* @param {object} [opts] Options to pass to the `Test` constructor.
|
|
17
|
+
* @returns {Test} A new test instance.
|
|
18
|
+
*/
|
|
19
|
+
module.exports.new = function(opts={})
|
|
20
|
+
{
|
|
21
|
+
return new Test(opts);
|
|
22
|
+
}
|
|
23
|
+
|
package/{src → lib}/log.js
RENAMED
|
File without changes
|
package/{src → lib}/test.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
const {F,S,N,isType,isInstance,def} =
|
|
1
|
+
const core = require('@lumjs/core');
|
|
2
|
+
const {F,S,N,isType,isObj,isInstance,def} = core.types;
|
|
3
3
|
|
|
4
4
|
// We use a separate class to represent test logs.
|
|
5
5
|
const Log = require('./log');
|
|
@@ -16,18 +16,59 @@ class Test
|
|
|
16
16
|
/**
|
|
17
17
|
* Build a new Test instance.
|
|
18
18
|
*
|
|
19
|
-
* @param {
|
|
20
|
-
*
|
|
19
|
+
* @param {object} [opts] Named options.
|
|
20
|
+
* @param {string} [opts.id] A unique test id, used by Harness.
|
|
21
|
+
* @param {number} [opts.plan] Passed to `plan()` method.
|
|
22
|
+
* @param {object} [opts.moduleName] Options for `core.modules.name()`.
|
|
23
|
+
* @param {object} [opts.module] The node module to export this test to.
|
|
24
|
+
*
|
|
25
|
+
* If you use this option, `opts.module.exports` will be assigned
|
|
26
|
+
* to the test instance, overriding anything that may have been
|
|
27
|
+
* assigned to it previously.
|
|
28
|
+
*
|
|
29
|
+
* Also, if this is passed, and `opts.id` was not specified, and id
|
|
30
|
+
* will be auto-generated based on the filename of the module.
|
|
31
|
+
*
|
|
21
32
|
*/
|
|
22
|
-
constructor (
|
|
33
|
+
constructor (opts={})
|
|
23
34
|
{
|
|
35
|
+
if (typeof opts === N)
|
|
36
|
+
{
|
|
37
|
+
opts = {plan: opts};
|
|
38
|
+
}
|
|
39
|
+
else if (typeof opts === S)
|
|
40
|
+
{
|
|
41
|
+
opts = {id: opts};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const hasModule = isObj(opts.module);
|
|
45
|
+
|
|
46
|
+
if (typeof opts.id === S)
|
|
47
|
+
{ // A specific id was specified.
|
|
48
|
+
this.id = opts.id;
|
|
49
|
+
}
|
|
50
|
+
else if (hasModule)
|
|
51
|
+
{ // We're going to generate a simple name.
|
|
52
|
+
this.id = core.modules.name(opts.module, opts.moduleName);
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
{ // An anonymous test.
|
|
56
|
+
this.id = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
24
59
|
this.failed = 0;
|
|
25
60
|
this.skipped = 0;
|
|
26
61
|
this.planned = 0;
|
|
27
62
|
this.log = [];
|
|
28
|
-
|
|
63
|
+
|
|
64
|
+
if (typeof opts.plan === N)
|
|
29
65
|
{
|
|
30
|
-
this.plan(plan);
|
|
66
|
+
this.plan(opts.plan);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (hasModule)
|
|
70
|
+
{ // Finally, if a module was passed, its going to export this test.
|
|
71
|
+
opts.module.exports = this;
|
|
31
72
|
}
|
|
32
73
|
}
|
|
33
74
|
|
package/package.json
CHANGED
package/test/basics.js
CHANGED
package/test/dies.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Testing the basic functions of the functional testing API.
|
|
2
2
|
|
|
3
|
-
const {test,plan,ok,pass,is,isnt,cmp,tap} = require('../
|
|
3
|
+
const {test,plan,ok,pass,is,isnt,cmp,tap} = require('../lib').functional();
|
|
4
4
|
const def = require('./inc/basics.js');
|
|
5
5
|
|
|
6
6
|
plan(def.plan);
|
package/test/functional_dies.js
CHANGED
package/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Several test related classes.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const Test = require('./src/test');
|
|
6
|
-
|
|
7
|
-
module.exports.Test = Test;
|
|
8
|
-
module.exports.Harness = require('./src/harness');
|
|
9
|
-
|
|
10
|
-
// This one is not a class, but a special function.
|
|
11
|
-
module.exports.functional = require('./src/functional');
|
|
12
|
-
|
|
13
|
-
// This one is a quick shortcut function.
|
|
14
|
-
module.exports.new = function({plan,module}={})
|
|
15
|
-
{
|
|
16
|
-
const test = new Test(plan);
|
|
17
|
-
if (module)
|
|
18
|
-
{
|
|
19
|
-
module.exports = test;
|
|
20
|
-
}
|
|
21
|
-
return test;
|
|
22
|
-
}
|
|
23
|
-
|