aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-05-14 18:20:34 +0200
committerGitHub <[email protected]>2024-05-14 16:20:34 +0000
commit7fb9bb52941e9c7bb458f1dc7cabb3737d05dffe (patch)
treeab99e6f2fae667f3af4fcd125a46dd989f769725 /test
parent044a75600d03cd7f7abfc3b0cbf98f909f1b1d08 (diff)
downloadfaker-7fb9bb52941e9c7bb458f1dc7cabb3737d05dffe.tar.xz
faker-7fb9bb52941e9c7bb458f1dc7cabb3737d05dffe.zip
infra(vitest): prefer-to-have-length (#2900)
Diffstat (limited to 'test')
-rw-r--r--test/modules/git.spec.ts2
-rw-r--r--test/modules/helpers.spec.ts8
-rw-r--r--test/modules/location.spec.ts4
3 files changed, 7 insertions, 7 deletions
diff --git a/test/modules/git.spec.ts b/test/modules/git.spec.ts
index 8957e995..e4692b20 100644
--- a/test/modules/git.spec.ts
+++ b/test/modules/git.spec.ts
@@ -134,7 +134,7 @@ describe('git', () => {
expect(commitDate).toBeTypeOf('string');
const parts = commitDate.split(' ');
- expect(parts.length).toBe(6);
+ expect(parts).toHaveLength(6);
});
});
diff --git a/test/modules/helpers.spec.ts b/test/modules/helpers.spec.ts
index 98c3488a..b9b59f22 100644
--- a/test/modules/helpers.spec.ts
+++ b/test/modules/helpers.spec.ts
@@ -402,7 +402,7 @@ describe('helpers', () => {
const subset = faker.helpers.arrayElements(testArray, 6);
// Check length
- expect(subset.length).toBe(5);
+ expect(subset).toHaveLength(5);
// Check elements
for (const element of subset) {
@@ -1078,7 +1078,7 @@ describe('helpers', () => {
const result = faker.helpers.multiple(() => faker.person.firstName());
expect(result).toBeTypeOf('object');
expect(Array.isArray(result)).toBe(true);
- expect(result.length).toBe(3);
+ expect(result).toHaveLength(3);
});
it('should generate the given amount of values from the function', () => {
@@ -1090,7 +1090,7 @@ describe('helpers', () => {
);
expect(result).toBeTypeOf('object');
expect(Array.isArray(result)).toBe(true);
- expect(result.length).toBe(5);
+ expect(result).toHaveLength(5);
});
it('should generate a ranged number of values from the function', () => {
@@ -1112,7 +1112,7 @@ describe('helpers', () => {
});
expect(result).toBeTypeOf('object');
expect(Array.isArray(result)).toBe(true);
- expect(result.length).toBe(3);
+ expect(result).toHaveLength(3);
expect(result).toStrictEqual([0, 2, 4]);
});
});
diff --git a/test/modules/location.spec.ts b/test/modules/location.spec.ts
index 86897ad5..dc82757d 100644
--- a/test/modules/location.spec.ts
+++ b/test/modules/location.spec.ts
@@ -193,7 +193,7 @@ describe('location', () => {
it('should return a zip code with length 5 for ZIP codes that start with 0', () => {
const zipCode = fakerEN_US.location.zipCode({ state: 'NH' });
- expect(zipCode.length).toBe(5);
+ expect(zipCode).toHaveLength(5);
});
it('should throw when definitions.location.postcode_by_state not set', () => {
@@ -367,7 +367,7 @@ describe('location', () => {
isMetric,
});
- expect(coordinate.length).toBe(2);
+ expect(coordinate).toHaveLength(2);
expect(coordinate[0]).toBeTypeOf('number');
expect(coordinate[1]).toBeTypeOf('number');