Skip to content

Commit d2fc1e6

Browse files
authored
fix: Vehicle vin is always 17 characters long (#320)
1 parent 8ab5eff commit d2fc1e6

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/vehicle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class Vehicle {
8282
bannedChars,
8383
})}${this.faker.random.alphaNumeric(1, {
8484
bannedChars,
85-
})}${this.faker.datatype.number({ min: 10000, max: 100000 })}` // return five digit #
85+
})}${this.faker.datatype.number({ min: 10000, max: 99999 })}` // return five digit #
8686
.toUpperCase();
8787
}
8888

test/vehicle.spec.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const seededRuns = [
2424
model: 'Colorado',
2525
type: 'Coupe',
2626
fuel: 'Electric',
27-
vin: '8J579HF1A7MK33575',
27+
vin: '8J579HF1A7MK33574',
2828
color: 'black',
2929
vrm: 'GO12HOL',
3030
bicycle: 'Cyclocross Bicycle',
@@ -38,7 +38,7 @@ const seededRuns = [
3838
model: '2',
3939
type: 'Wagon',
4040
fuel: 'Hybrid',
41-
vin: 'XFWS74Z1N5S678768',
41+
vin: 'XFWS74Z1N5S678767',
4242
color: 'azure',
4343
vrm: 'YL87FDZ',
4444
bicycle: 'Triathlon/Time Trial Bicycle',
@@ -107,6 +107,15 @@ describe('vehicle', () => {
107107
});
108108
});
109109

110+
describe('vin()', () => {
111+
it('returns valid vin number', () => {
112+
const vin = faker.vehicle.vin();
113+
expect(vin).toMatch(
114+
/^([A-HJ-NPR-Z0-9]{10}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5})$/
115+
);
116+
});
117+
});
118+
110119
describe('model()', () => {
111120
it('should return random vehicle model', () => {
112121
const model = faker.vehicle.model();

0 commit comments

Comments
 (0)