Files
codeql-action/node_modules/ava/lib/parse-test-args.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
701 B
JavaScript
Raw Normal View History

2022-02-01 18:01:11 +00:00
const buildTitle = (raw, implementation, args) => {
let value = implementation && implementation.title ? implementation.title(raw, ...args) : raw;
const isValid = typeof value === 'string';
if (isValid) {
value = value.trim().replace(/\s+/g, ' ');
}
2020-05-04 18:50:13 +01:00
2022-02-01 18:01:11 +00:00
return {
raw,
value,
isSet: value !== undefined,
isValid,
isEmpty: !isValid || value === '',
2020-05-04 18:50:13 +01:00
};
2022-02-01 18:01:11 +00:00
};
2020-05-04 18:50:13 +01:00
2022-02-01 18:01:11 +00:00
export default function parseTestArgs(args) {
const rawTitle = typeof args[0] === 'string' ? args.shift() : undefined;
const implementation = args.shift();
2020-05-04 18:50:13 +01:00
2022-02-01 18:01:11 +00:00
return {
args,
implementation: implementation && implementation.exec ? implementation.exec : implementation,
title: buildTitle(rawTitle, implementation, args),
};
}