Skip to content

Commit aaefb07

Browse files
authored
Adds type to toConfigList (#7)
1 parent 57c5c7e commit aaefb07

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"keywords": [
55
"unit-testing"
66
],
7-
"version": "0.15.0",
7+
"version": "0.16.0",
88
"author": {
99
"name": "Olivier Huin",
1010
"url": "https://github.com/olih"

src/runner.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { fdir } from 'fdir';
22

3-
type ToConfigFunction = (specFile: string) => { specFile: string };
4-
53
const isStringArray = (value: unknown): value is string[] =>
64
typeof value === 'object' && value !== null && Array.isArray(value);
75

@@ -11,10 +9,10 @@ const isStringArray = (value: unknown): value is string[] =>
119
* @param toConfigWrapper function that takes a specFile and return the config
1210
* @returns a list of configurations for the runner
1311
*/
14-
export const toConfigList = async (
12+
export async function toConfigList<A>(
1513
specDir: string,
16-
toConfigWrapper: ToConfigFunction
17-
): Promise<{ specFile: string }[]> => {
14+
toConfigWrapper: (specFile: string) => A
15+
): Promise<A[]> {
1816
const crawler = new fdir()
1917
.withBasePath()
2018
.filter((path) => path.endsWith('.zest.yaml'));
@@ -24,4 +22,4 @@ export const toConfigList = async (
2422
} else {
2523
return [];
2624
}
27-
};
25+
}

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = '0.15.0';
1+
export const version = '0.16.0';

test/runner.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ import { it } from 'node:test';
22
import { deepStrictEqual } from 'node:assert';
33
import { toConfigList } from '../src/runner.js';
44

5-
const toConfigFunction = (specFile: string) => ({ specFile });
5+
const toConfigFunction = (specFile: string) => ({ specFile , additional: 'info'});
66

77
it('should search for spec files', async () => {
88
const actual = await toConfigList('spec', toConfigFunction);
99
deepStrictEqual(actual, [
1010
{
1111
specFile: 'spec/dummy.zest.yaml',
12+
additional: 'info',
1213
},
1314
{
1415
specFile: 'spec/level2/dummy2.zest.yaml',
16+
additional: 'info',
1517
},
1618
]);
1719
});

0 commit comments

Comments
 (0)