Skip to content

Commit d1d286d

Browse files
committed
fix: Vehicle vin is always 17 characters long
1 parent 3242dfc commit d1d286d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/vehicle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class Vehicle {
8484
bannedChars: bannedChars,
8585
}) +
8686
this.faker.random.alphaNumeric(1, { bannedChars: bannedChars }) +
87-
this.faker.datatype.number({ min: 10000, max: 100000 })
87+
this.faker.datatype.number({ min: 10000, max: 99999 })
8888
) // return five digit #
8989
.toUpperCase();
9090
}

test/vehicle.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ describe('vehicle', () => {
5858
/^([A-HJ-NPR-Z0-9]{10}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5})$/
5959
);
6060
});
61+
62+
it('is 17 characters long', () => {
63+
for (let step = 0; step < 300000; step++) {
64+
const vin = faker.vehicle.vin();
65+
expect(vin).match(
66+
/^([A-HJ-NPR-Z0-9]{10}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5})$/
67+
);
68+
}
69+
});
6170
});
6271

6372
describe('color()', () => {

0 commit comments

Comments
 (0)