Skip to content

Commit 9f3acb7

Browse files
committed
feat(title): include index and times in full title, close #1
1 parent 2f47bfd commit 9f3acb7

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ output:
4747

4848
```
4949
repeat-it
50-
✓ 1 repeated test
51-
✓ 2 repeated test
52-
✓ 3 repeated test
53-
✓ 4 repeated test
54-
✓ 5 repeated test
55-
✓ 6 repeated test
56-
✓ 7 repeated test
57-
✓ 8 repeated test
58-
✓ 9 repeated test
59-
✓ 10 repeated test
50+
✓ 1/10 repeated test
51+
✓ 2/10 repeated test
52+
✓ 3/10 repeated test
53+
✓ 4/10 repeated test
54+
✓ 5/10 repeated test
55+
✓ 6/10 repeated test
56+
✓ 7/10 repeated test
57+
✓ 8/10 repeated test
58+
✓ 9/10 repeated test
59+
✓ 10/10 repeated test
6060
6161
10 passing (10ms)
6262
```

src/index.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ function checkTimes (times) {
2121
console.assert(isNonNegative(times), 'repeat times should be non-negative')
2222
}
2323

24+
function formatMessage (title, times) {
25+
return function finishFormat (k) {
26+
return k + 1 + '/' + times + ' ' + title
27+
}
28+
}
29+
2430
function only (times) {
2531
if (!isNumber(times)) {
2632
// probably plain it('name', ...) call
@@ -31,8 +37,9 @@ function only (times) {
3137

3238
return function (title, fn) {
3339
let k
40+
const fullTitle = formatMessage(title, times)
3441
for (k = 0; k < times; k += 1) {
35-
oldIt.only(k + 1 + ' ' + title, fn)
42+
oldIt.only(fullTitle(k), fn)
3643
}
3744
}
3845
}
@@ -47,8 +54,9 @@ function repeatIt (times) {
4754

4855
return function (title, fn) {
4956
let k
57+
const fullTitle = formatMessage(title, times)
5058
for (k = 0; k < times; k += 1) {
51-
oldIt(k + 1 + ' ' + title, fn)
59+
oldIt(fullTitle(k), fn)
5260
}
5361
}
5462
}

0 commit comments

Comments
 (0)