@webex/jsdoctrinetest 2.59.2 → 2.59.3-next.1
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/.eslintrc.js +6 -6
- package/README.md +51 -51
- package/babel.config.js +3 -3
- package/dist/assertions/literal.js +14 -14
- package/dist/assertions/literal.js.map +1 -1
- package/dist/extract.js +23 -23
- package/dist/extract.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mocha-template.js +8 -8
- package/dist/mocha-template.js.map +1 -1
- package/dist/parse.js +7 -7
- package/dist/parse.js.map +1 -1
- package/dist/transform.js +13 -13
- package/dist/transform.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +13 -12
- package/process +1 -1
- package/src/assertions/literal.js +73 -73
- package/src/extract.js +119 -119
- package/src/index.js +55 -55
- package/src/mocha-template.js +43 -43
- package/src/parse.js +38 -38
- package/src/transform.js +68 -68
- package/test/unit/spec/default.js +11 -11
package/src/transform.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import template from '@babel/template';
|
|
6
|
-
import traverse from '@babel/traverse';
|
|
7
|
-
|
|
8
|
-
import parse from './parse';
|
|
9
|
-
import generateSpec from './mocha-template';
|
|
10
|
-
import {build as buildLiteralAssertion, test as literalAssertionTest} from './assertions/literal';
|
|
11
|
-
|
|
12
|
-
const assertionStatementTemplate = template(`
|
|
13
|
-
return Promise.resolve(ORIGINAL)
|
|
14
|
-
.then(function(result) {
|
|
15
|
-
ASSERTIONS
|
|
16
|
-
})
|
|
17
|
-
`);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {Object} options
|
|
21
|
-
* @param {ast} options.comment
|
|
22
|
-
* @param {string} options.name
|
|
23
|
-
* @param {string} options.filename
|
|
24
|
-
* @param {string} options.type
|
|
25
|
-
* @returns {ast}
|
|
26
|
-
*/
|
|
27
|
-
export default function transform({comment, name, filename, type}) {
|
|
28
|
-
const ast = parse(comment);
|
|
29
|
-
|
|
30
|
-
traverse(ast, {
|
|
31
|
-
enter(path) {
|
|
32
|
-
if (path.node.trailingComments) {
|
|
33
|
-
const assertions = path.node.trailingComments.map(makeAsserter);
|
|
34
|
-
|
|
35
|
-
if (assertions.length) {
|
|
36
|
-
Reflect.deleteProperty(path.node, 'trailingComments');
|
|
37
|
-
|
|
38
|
-
path.replaceWith(
|
|
39
|
-
assertionStatementTemplate({
|
|
40
|
-
ORIGINAL: path.node,
|
|
41
|
-
ASSERTIONS: assertions,
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return generateSpec({
|
|
50
|
-
testCase: ast,
|
|
51
|
-
name,
|
|
52
|
-
filename,
|
|
53
|
-
type,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Takes a trailing comment from an example block and changes it to an assertion
|
|
59
|
-
* @param {CommentBlock} comment
|
|
60
|
-
* @returns {ast}
|
|
61
|
-
*/
|
|
62
|
-
function makeAsserter(comment) {
|
|
63
|
-
if (literalAssertionTest(comment.value)) {
|
|
64
|
-
return buildLiteralAssertion(comment.value);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import template from '@babel/template';
|
|
6
|
+
import traverse from '@babel/traverse';
|
|
7
|
+
|
|
8
|
+
import parse from './parse';
|
|
9
|
+
import generateSpec from './mocha-template';
|
|
10
|
+
import {build as buildLiteralAssertion, test as literalAssertionTest} from './assertions/literal';
|
|
11
|
+
|
|
12
|
+
const assertionStatementTemplate = template(`
|
|
13
|
+
return Promise.resolve(ORIGINAL)
|
|
14
|
+
.then(function(result) {
|
|
15
|
+
ASSERTIONS
|
|
16
|
+
})
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {Object} options
|
|
21
|
+
* @param {ast} options.comment
|
|
22
|
+
* @param {string} options.name
|
|
23
|
+
* @param {string} options.filename
|
|
24
|
+
* @param {string} options.type
|
|
25
|
+
* @returns {ast}
|
|
26
|
+
*/
|
|
27
|
+
export default function transform({comment, name, filename, type}) {
|
|
28
|
+
const ast = parse(comment);
|
|
29
|
+
|
|
30
|
+
traverse(ast, {
|
|
31
|
+
enter(path) {
|
|
32
|
+
if (path.node.trailingComments) {
|
|
33
|
+
const assertions = path.node.trailingComments.map(makeAsserter);
|
|
34
|
+
|
|
35
|
+
if (assertions.length) {
|
|
36
|
+
Reflect.deleteProperty(path.node, 'trailingComments');
|
|
37
|
+
|
|
38
|
+
path.replaceWith(
|
|
39
|
+
assertionStatementTemplate({
|
|
40
|
+
ORIGINAL: path.node,
|
|
41
|
+
ASSERTIONS: assertions,
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return generateSpec({
|
|
50
|
+
testCase: ast,
|
|
51
|
+
name,
|
|
52
|
+
filename,
|
|
53
|
+
type,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Takes a trailing comment from an example block and changes it to an assertion
|
|
59
|
+
* @param {CommentBlock} comment
|
|
60
|
+
* @returns {ast}
|
|
61
|
+
*/
|
|
62
|
+
function makeAsserter(comment) {
|
|
63
|
+
if (literalAssertionTest(comment.value)) {
|
|
64
|
+
return buildLiteralAssertion(comment.value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {assert} from '@webex/test-helper-chai';
|
|
6
|
-
|
|
7
|
-
describe('jsdoctrinetest', () => {
|
|
8
|
-
it('has just enough of a test suite to not crash the test suite', () => {
|
|
9
|
-
assert.isTrue(true);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {assert} from '@webex/test-helper-chai';
|
|
6
|
+
|
|
7
|
+
describe('jsdoctrinetest', () => {
|
|
8
|
+
it('has just enough of a test suite to not crash the test suite', () => {
|
|
9
|
+
assert.isTrue(true);
|
|
10
|
+
});
|
|
11
|
+
});
|