forked from zuriby/Faker.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vehicle.js
114 lines (98 loc) · 2.37 KB
/
vehicle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
*
* @namespace faker.vehicle
*/
var Vehicle = function (faker) {
var self = this;
var fake = faker.fake;
/**
* vehicle
*
* @method faker.vehicle.vehicle
*/
self.vehicle = function () {
return fake('{{vehicle.manufacturer}} {{vehicle.model}}');
};
self.vehicle.schema = {
"description": "Generates a random vehicle.",
"sampleResults": ["BMW Explorer", "Ford Camry", "Lamborghini Ranchero"]
};
/**
* manufacturer
*
* @method faker.vehicle.manufacturer
*/
self.manufacturer = function () {
return faker.random.arrayElement(faker.definitions.vehicle.manufacturer);
};
self.manufacturer.schema = {
"description": "Generates a manufacturer name.",
"sampleResults": ["Ford", "Jeep", "Tesla"]
};
/**
* model
*
* @method faker.vehicle.model
*/
self.model = function () {
return faker.random.arrayElement(faker.definitions.vehicle.model);
};
self.model.schema = {
"description": "Generates a vehicle model.",
"sampleResults": ["Explorer", "Camry", "Ranchero"]
};
/**
* type
*
* @method faker.vehicle.type
*/
self.type = function () {
return faker.random.arrayElement(faker.definitions.vehicle.type);
};
self.type.schema = {
"description": "Generates a vehicle type.",
"sampleResults": ["Coupe", "Convertable", "Sedan", "SUV"]
};
/**
* fuel
*
* @method faker.vehicle.fuel
*/
self.fuel = function () {
return faker.random.arrayElement(faker.definitions.vehicle.fuel);
};
self.fuel.schema = {
"description": "Generates a fuel type.",
"sampleResults": ["Electric", "Gasoline", "Diesel"]
};
/**
* vin
*
* @method faker.vehicle.vin
*/
self.vin = function () {
return (
faker.random.alphaNumeric(10) +
faker.random.alpha({ count: 1, upcase: true }) +
faker.random.alphaNumeric(1) +
faker.random.number({ min: 10000, max: 100000}) // return five digit #
).toUpperCase();
};
self.vin.schema = {
"description": "Generates a valid VIN number.",
"sampleResults": ["YV1MH682762184654", "3C7WRMBJ2EG208836"]
};
/**
* color
*
* @method faker.vehicle.color
*/
self.color = function () {
return fake('{{commerce.color}}');
};
self.color.schema = {
"description": "Generates a color",
"sampleResults": ["red", "white", "black"]
};
};
module["exports"] = Vehicle;