UNPKG

633 BJavaScriptView Raw
1'use strict';
2function parseTestArgs(args) {
3 const rawTitle = typeof args[0] === 'string' ? args.shift() : undefined;
4 const receivedImplementationArray = Array.isArray(args[0]);
5 const implementations = receivedImplementationArray ? args.shift() : args.splice(0, 1);
6
7 const buildTitle = implementation => {
8 const title = implementation.title ? implementation.title(rawTitle, ...args) : rawTitle;
9 return {title, isSet: typeof title !== 'undefined', isValid: typeof title === 'string', isEmpty: !title};
10 };
11
12 return {args, buildTitle, implementations, rawTitle, receivedImplementationArray};
13}
14
15module.exports = parseTestArgs;