Skip to content

Commit

Permalink
fix: Vehicle vin is always 17 characters long (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
demipel8 committed Mar 28, 2022
1 parent 8ab5eff commit d2fc1e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class Vehicle {
bannedChars,
})}${this.faker.random.alphaNumeric(1, {
bannedChars,
})}${this.faker.datatype.number({ min: 10000, max: 100000 })}` // return five digit #
})}${this.faker.datatype.number({ min: 10000, max: 99999 })}` // return five digit #
.toUpperCase();
}

Expand Down
13 changes: 11 additions & 2 deletions test/vehicle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const seededRuns = [
model: 'Colorado',
type: 'Coupe',
fuel: 'Electric',
vin: '8J579HF1A7MK33575',
vin: '8J579HF1A7MK33574',
color: 'black',
vrm: 'GO12HOL',
bicycle: 'Cyclocross Bicycle',
Expand All @@ -38,7 +38,7 @@ const seededRuns = [
model: '2',
type: 'Wagon',
fuel: 'Hybrid',
vin: 'XFWS74Z1N5S678768',
vin: 'XFWS74Z1N5S678767',
color: 'azure',
vrm: 'YL87FDZ',
bicycle: 'Triathlon/Time Trial Bicycle',
Expand Down Expand Up @@ -107,6 +107,15 @@ describe('vehicle', () => {
});
});

describe('vin()', () => {
it('returns valid vin number', () => {
const vin = faker.vehicle.vin();
expect(vin).toMatch(
/^([A-HJ-NPR-Z0-9]{10}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5})$/
);
});
});

describe('model()', () => {
it('should return random vehicle model', () => {
const model = faker.vehicle.model();
Expand Down

0 comments on commit d2fc1e6

Please sign in to comment.