Skip to content

Commit 542ad20

Browse files
committed
Rename variables
1 parent 42ba440 commit 542ad20

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

test/helpers/test_each/name.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
import { serializeArg } from './serialize.js'
22

3-
// Retrieve unique test titles for each iteration.
3+
// Retrieve unique test names for each iteration.
44
// To customize names inside a specific iterable, add `name` properties to it,
55
// for example with `Array.map()`.
6-
// To customize whole titles, generate them inside the iterated function using
6+
// To customize whole names, generate them inside the iterated function using
77
// all values.
88
export const getNames = function(args) {
9-
return args.map(getTitle).map(fixDuplicate)
9+
return args.map(getName).map(fixDuplicate)
1010
}
1111

12-
const getTitle = function(args) {
13-
return args.map(getName).join(' ')
12+
const getName = function(args) {
13+
const argNames = args.map(getArgName)
14+
const name = argNames.join(' ')
15+
return name
1416
}
1517

16-
const getName = function(arg) {
17-
const name = serializeArg(arg)
18-
const nameA = name.trim()
19-
const nameB = truncateName(nameA)
20-
return nameB
18+
const getArgName = function(arg) {
19+
const argName = serializeArg(arg)
20+
const argNameA = argName.trim()
21+
const argNameB = truncateName(argNameA)
22+
return argNameB
2123
}
2224

2325
// Make names short by truncating them
24-
const truncateName = function(name) {
25-
if (name.length <= MAX_NAME_LENGTH) {
26-
return name
26+
const truncateName = function(argName) {
27+
if (argName.length <= MAX_NAME_LENGTH) {
28+
return argName
2729
}
2830

29-
const nameA = name.slice(0, MAX_NAME_LENGTH)
30-
return `${nameA}...`
31+
const argNameA = argName.slice(0, MAX_NAME_LENGTH)
32+
return `${argNameA}...`
3133
}
3234

3335
const MAX_NAME_LENGTH = 60
3436

35-
// Ensure titles are unique by appending the index when we find duplicates
36-
const fixDuplicate = function(title, index, titles) {
37-
if (!isDuplicate(title, index, titles)) {
38-
return title
37+
// Ensure names are unique by appending the index when we find duplicates
38+
const fixDuplicate = function(name, index, names) {
39+
if (!isDuplicate(name, index, names)) {
40+
return name
3941
}
4042

41-
return `${title} (${index})`
43+
return `${name} (${index})`
4244
}
4345

44-
const isDuplicate = function(title, index, titles) {
45-
return titles.some((titleA, indexA) => titleA === title && index !== indexA)
46+
const isDuplicate = function(name, index, names) {
47+
return names.some((nameA, indexA) => nameA === name && index !== indexA)
4648
}

0 commit comments

Comments
 (0)