Skip to content

Commit c1bc38f

Browse files
committed
fix(mock): replace negated conditions to satisfy unicorn/no-negated-condition
1 parent 932fa58 commit c1bc38f

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

packages/mock/src/faker/getters/scalar.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ describe('getMockScalar (undefined filtering)', () => {
445445
);
446446
});
447447

448-
it('should use min: 1 when only maxLength is specified', () => {
448+
it('should include only max when only maxLength is specified', () => {
449449
const result = getMockScalar({
450450
...baseArg,
451451
item: {
@@ -455,7 +455,7 @@ describe('getMockScalar (undefined filtering)', () => {
455455
},
456456
});
457457

458-
expect(result.value).toBe('faker.string.alpha({length: {min: 1, max: 5}})');
458+
expect(result.value).toBe('faker.string.alpha({length: {max: 5}})');
459459
});
460460

461461
it('should include only min when only minLength is specified', () => {
@@ -471,7 +471,7 @@ describe('getMockScalar (undefined filtering)', () => {
471471
expect(result.value).toBe('faker.string.alpha({length: {min: 30}})');
472472
});
473473

474-
it('should use min: 1 when only maxItems is specified', () => {
474+
it('should include only max when only maxItems is specified', () => {
475475
const result = getMockScalar({
476476
...baseArg,
477477
item: {
@@ -482,7 +482,7 @@ describe('getMockScalar (undefined filtering)', () => {
482482
},
483483
});
484484

485-
expect(result.value).toContain('faker.number.int({min: 1, max: 5})');
485+
expect(result.value).toContain('faker.number.int({max: 5})');
486486
});
487487

488488
it('should include only min when only minItems is specified', () => {

packages/mock/src/faker/getters/scalar.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ export function getMockScalar({
268268
}
269269

270270
const arrMin = (item.minItems ??
271-
(item.maxItems !== undefined ? 1 : safeMockOptions.arrayMin)) as
272-
| number
273-
| undefined;
271+
(item.maxItems === undefined
272+
? safeMockOptions.arrayMin
273+
: undefined)) as number | undefined;
274274
const arrMax = (item.maxItems ??
275-
(item.minItems !== undefined
276-
? undefined
277-
: safeMockOptions.arrayMax)) as number | undefined;
275+
(item.minItems === undefined
276+
? safeMockOptions.arrayMax
277+
: undefined)) as number | undefined;
278278
const arrParts: string[] = [];
279279
if (arrMin !== undefined) arrParts.push(`min: ${arrMin}`);
280280
if (arrMax !== undefined) arrParts.push(`max: ${arrMax}`);
@@ -293,13 +293,13 @@ export function getMockScalar({
293293

294294
case 'string': {
295295
const strMin = (item.minLength ??
296-
(item.maxLength !== undefined ? 1 : safeMockOptions.stringMin)) as
297-
| number
298-
| undefined;
296+
(item.maxLength === undefined
297+
? safeMockOptions.stringMin
298+
: undefined)) as number | undefined;
299299
const strMax = (item.maxLength ??
300-
(item.minLength !== undefined
301-
? undefined
302-
: safeMockOptions.stringMax)) as number | undefined;
300+
(item.minLength === undefined
301+
? safeMockOptions.stringMax
302+
: undefined)) as number | undefined;
303303
const strLenParts: string[] = [];
304304
if (strMin !== undefined) strLenParts.push(`min: ${strMin}`);
305305
if (strMax !== undefined) strLenParts.push(`max: ${strMax}`);

0 commit comments

Comments
 (0)