Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Vehicle vin is always 17 characters long #320

Merged
merged 5 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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