Skip to content

Commit 2ba5edb

Browse files
authored
chore: improve variable naming of system module (#3315)
* chore: improve variable naming of system module * chore: rename variables in tests
1 parent 1bfa1fa commit 2ba5edb

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

src/modules/system/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,32 +77,32 @@ export class SystemModule extends ModuleBase {
7777
.toLowerCase()
7878
.replaceAll(/\W/g, '_');
7979

80-
const extensionsStr = this.faker.helpers
80+
const extensionsSuffix = this.faker.helpers
8181
.multiple(() => this.fileExt(), { count: extensionCount })
8282
.join('.');
8383

84-
if (extensionsStr.length === 0) {
84+
if (extensionsSuffix.length === 0) {
8585
return baseName;
8686
}
8787

88-
return `${baseName}.${extensionsStr}`;
88+
return `${baseName}.${extensionsSuffix}`;
8989
}
9090

9191
/**
9292
* Returns a random file name with a given extension or a commonly used extension.
9393
*
94-
* @param ext Extension. Empty string is considered to be not set.
94+
* @param extension The file extension to use. Empty string is considered to be not set.
9595
*
9696
* @example
9797
* faker.system.commonFileName() // 'dollar.jpg'
9898
* faker.system.commonFileName('txt') // 'global_borders_wyoming.txt'
9999
*
100100
* @since 3.1.0
101101
*/
102-
commonFileName(ext?: string): string {
103-
const str = this.fileName({ extensionCount: 0 });
102+
commonFileName(extension?: string): string {
103+
const fileName = this.fileName({ extensionCount: 0 });
104104

105-
return `${str}.${ext || this.commonFileExt()}`;
105+
return `${fileName}.${extension || this.commonFileExt()}`;
106106
}
107107

108108
/**

test/modules/system.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ describe('system', () => {
6666
() => {
6767
describe('commonFileExt()', () => {
6868
it('should return common file types', () => {
69-
const fileExt = faker.system.commonFileExt();
70-
const extList = [
69+
const actual = faker.system.commonFileExt();
70+
const extensions = [
7171
'gif',
7272
'htm',
7373
'html',
@@ -96,11 +96,11 @@ describe('system', () => {
9696
];
9797

9898
expect(
99-
extList,
100-
`generated common file ext should be one of [${extList.join(
99+
extensions,
100+
`generated common file ext should be one of [${extensions.join(
101101
', '
102-
)}]. Got "${fileExt}".`
103-
).include(fileExt);
102+
)}]. Got "${actual}".`
103+
).include(actual);
104104
});
105105
});
106106

@@ -164,15 +164,15 @@ describe('system', () => {
164164

165165
describe('fileExt()', () => {
166166
it('should return file ext', () => {
167-
const fileExt = faker.system.fileExt();
167+
const actual = faker.system.fileExt();
168168

169-
expect(fileExt).toBeTypeOf('string');
170-
expect(fileExt).not.toBe('');
169+
expect(actual).toBeTypeOf('string');
170+
expect(actual).not.toBe('');
171171
});
172172

173173
it('should return file ext based on mimeType', () => {
174-
const fileExt = faker.system.fileExt('text/plain');
175-
const extList = [
174+
const actual = faker.system.fileExt('text/plain');
175+
const extensions = [
176176
'txt',
177177
'text',
178178
'conf',
@@ -184,11 +184,11 @@ describe('system', () => {
184184
];
185185

186186
expect(
187-
extList,
188-
`generated common file ext should be one of [${extList.join(
187+
extensions,
188+
`generated common file ext should be one of [${extensions.join(
189189
','
190-
)}]. Got "${fileExt}".`
191-
).include(fileExt);
190+
)}]. Got "${actual}".`
191+
).include(actual);
192192
});
193193
});
194194

0 commit comments

Comments
 (0)