@markedjs/testutils 9.1.0-1 → 9.1.0-3
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/README.md +18 -3
- package/package.json +1 -1
- package/src/get-tests.js +19 -24
- package/test/get-tests.test.js +0 -8
package/README.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# @markedjs/testutils
|
|
2
2
|
|
|
3
|
-
Test utilities for marked and marked extensions
|
|
3
|
+
Test utilities for marked and marked extensions.
|
|
4
|
+
|
|
5
|
+
## Versioning
|
|
6
|
+
|
|
7
|
+
This is versioned as the version of marked that it includes tests for with the prerelease version being an integer that gets incremented when we release a new fix or feature without updating the marked version.
|
|
8
|
+
|
|
9
|
+
We recommend to pin to a single version instead of using a range since any update may contain breaking changes.
|
|
10
|
+
|
|
11
|
+
**Example**
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
// package.json
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@markedjs/testutils": "9.1.0-0"
|
|
17
|
+
}
|
|
18
|
+
```
|
|
4
19
|
|
|
5
20
|
## API
|
|
6
21
|
|
|
@@ -11,8 +26,8 @@ Get all marked [Tests](#tests)
|
|
|
11
26
|
### `getTests(dirs)`
|
|
12
27
|
|
|
13
28
|
Get [Tests](#tests) from a directory or file.
|
|
14
|
-
`dirs` can be a string
|
|
15
|
-
The return type is the same as the input a Tests object
|
|
29
|
+
`dirs` can be a string or an array of strings.
|
|
30
|
+
The return type is the same as the input a Tests object or an array of Tests objects.
|
|
16
31
|
|
|
17
32
|
### `htmlIsEqual(actual, expected)`
|
|
18
33
|
|
package/package.json
CHANGED
package/src/get-tests.js
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
import { loadTests } from "./load-tests.js";
|
|
2
|
-
import {
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Get tests from a directory or file
|
|
6
|
-
* @param {string | [
|
|
7
|
-
* @returns {Tests | [
|
|
6
|
+
* @param {string | string[]} dirs Can be a string or an array of strings
|
|
7
|
+
* @returns {Tests | Tests[]} The return type will match the input, a tests object or an array of tests objects
|
|
8
8
|
*/
|
|
9
9
|
export async function getTests(dirs) {
|
|
10
|
-
if (typeof dirs === "string") {
|
|
11
|
-
return await loadTests(dirs);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
if (Array.isArray(dirs)) {
|
|
15
11
|
return await Promise.all(dirs.map((dir) => loadTests(dir)));
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
const tests = await Promise.all(keys.map((key) => loadTests(dirs[key])));
|
|
20
|
-
const testsObj = {};
|
|
21
|
-
for (let i = 0; i < keys.length; i++) {
|
|
22
|
-
testsObj[keys[i]] = tests[i];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return testsObj;
|
|
14
|
+
return await loadTests(dirs);
|
|
26
15
|
}
|
|
27
16
|
|
|
28
17
|
/**
|
|
@@ -36,13 +25,19 @@ export async function getTests(dirs) {
|
|
|
36
25
|
* }} All marked spec tests
|
|
37
26
|
*/
|
|
38
27
|
export async function getAllMarkedSpecTests() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
const tests = await getTests([
|
|
29
|
+
resolve("./node_modules/marked-repo/test/specs/commonmark"),
|
|
30
|
+
resolve("./node_modules/marked-repo/test/specs/gfm"),
|
|
31
|
+
resolve("./node_modules/marked-repo/test/specs/new"),
|
|
32
|
+
resolve("./node_modules/marked-repo/test/specs/original"),
|
|
33
|
+
resolve("./node_modules/marked-repo/test/specs/redos"),
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
CommonMark: tests[0],
|
|
38
|
+
GFM: tests[1],
|
|
39
|
+
New: tests[2],
|
|
40
|
+
Original: tests[3],
|
|
41
|
+
ReDOS: tests[4],
|
|
42
|
+
};
|
|
48
43
|
}
|
package/test/get-tests.test.js
CHANGED
|
@@ -19,12 +19,4 @@ test("get-tests", async (t) => {
|
|
|
19
19
|
|
|
20
20
|
assert.ok(tests[0].Tabs);
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
await t.test("getTests(obj)", async () => {
|
|
24
|
-
const tests = await getTests({
|
|
25
|
-
test: resolvePath("../node_modules/marked-repo/test/specs/commonmark"),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
assert.ok(tests.test.Tabs);
|
|
29
|
-
});
|
|
30
22
|
});
|