aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/prefix-title.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ava/lib/prefix-title.js')
-rw-r--r--node_modules/ava/lib/prefix-title.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/node_modules/ava/lib/prefix-title.js b/node_modules/ava/lib/prefix-title.js
new file mode 100644
index 000000000..a1c7b4f3b
--- /dev/null
+++ b/node_modules/ava/lib/prefix-title.js
@@ -0,0 +1,21 @@
+'use strict';
+const path = require('path');
+
+module.exports = (file, base, separator) => {
+ let prefix = file
+ // Only replace this.base if it is found at the start of the path
+ .replace(base, (match, offset) => offset === 0 ? '' : match)
+ .replace(/\.spec/, '')
+ .replace(/\.test/, '')
+ .replace(/test-/g, '')
+ .replace(/\.js$/, '')
+ .split(path.sep)
+ .filter(p => p !== '__tests__')
+ .join(separator);
+
+ if (prefix.length > 0) {
+ prefix += separator;
+ }
+
+ return prefix;
+};