@markedjs/testutils 9.1.0-1 → 9.1.0-2

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 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, an array of strings, or an object with string values.
15
- The return type is the same as the input a Tests object, an array of Tests objects, or an object with Tests object values.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markedjs/testutils",
3
- "version": "9.1.0-1",
3
+ "version": "9.1.0-2",
4
4
  "description": "Test utilities for marked and marked extensions",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/get-tests.js CHANGED
@@ -3,26 +3,15 @@ import { resolvePath } from "./helpers.js";
3
3
 
4
4
  /**
5
5
  * Get tests from a directory or file
6
- * @param {string | [string] | {key: string}} dirs Can be a string, array of strings, or an object with string values
7
- * @returns {Tests | [Tests] | {key: Tests}} The return type will match the input, a tests object, array of tests objects, or an object with tests objects values
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
- const keys = Object.keys(dirs);
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
- return await getTests({
40
- CommonMark: resolvePath(
41
- "../node_modules/marked-repo/test/specs/commonmark",
42
- ),
43
- GFM: resolvePath("../node_modules/marked-repo/test/specs/gfm"),
44
- New: resolvePath("../node_modules/marked-repo/test/specs/new"),
45
- Original: resolvePath("../node_modules/marked-repo/test/specs/original"),
46
- ReDOS: resolvePath("../node_modules/marked-repo/test/specs/redos"),
47
- });
28
+ const tests = await getTests([
29
+ resolvePath("../node_modules/marked-repo/test/specs/commonmark"),
30
+ resolvePath("../node_modules/marked-repo/test/specs/gfm"),
31
+ resolvePath("../node_modules/marked-repo/test/specs/new"),
32
+ resolvePath("../node_modules/marked-repo/test/specs/original"),
33
+ resolvePath("../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
  }
@@ -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
  });