-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-functions.js
62 lines (58 loc) · 2.17 KB
/
my-functions.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
'use strict';
module.exports = {
generateRandomData
};
const {
name,
urls,
coords,
addresses,
phoneNumbers,
hours,
} = require('./db/data.js');
function generateRandomData(userContext, events, done) {
const n = Math.floor((Math.random() * 100) + 0);
const id = Math.floor((Math.random() * 10000000) + 0);
const restaurantName = name[n];
const address = addresses[n];
const coordinates = coords[n];
const phonenumber = phoneNumbers[n];
const website = urls[n];
const monHoursOpen = hours[n].Monday.open;
const monHoursClose = hours[n].Monday.close;
const tuesHoursOpen = hours[n].Tuesday.open;
const tuesHoursClose = hours[n].Tuesday.close;
const wedsHoursOpen = hours[n].Wednesday.open;
const wedsHoursClose = hours[n].Wednesday.close;
const thursHoursOpen = hours[n].Thursday.open;
const thursHoursClose = hours[n].Thursday.close;
const friHoursOpen = hours[n].Friday.open;
const friHoursClose = hours[n].Friday.close;
const satHoursOpen = hours[n].Saturday.open;
const satHoursClose = hours[n].Saturday.close;
const sunHoursOpen = hours[n].Sunday.open;
const sunHoursClose = hours[n].Sunday.close;
// add variables to virtual user's context:
userContext.vars.id = id;
userContext.vars.restaurantName = restaurantName;
userContext.vars.address = address;
userContext.vars.coordinates = coordinates;
userContext.vars.website = website;
userContext.vars.phonenumber = phonenumber;
userContext.vars.monOpenHours = monHoursOpen;
userContext.vars.monHoursClose = monHoursClose;
userContext.vars.tuesHoursOpen = tuesHoursOpen;
userContext.vars.tuesHoursClose = tuesHoursClose;
userContext.vars.wedsHoursOpen = wedsHoursOpen;
userContext.vars.wedsHoursClose = wedsHoursClose;
userContext.vars.thursHoursOpen = thursHoursOpen;
userContext.vars.thursHoursClose = thursHoursClose;
userContext.vars.friHoursOpen = friHoursOpen;
userContext.vars.friHoursClose = friHoursClose;
userContext.vars.satHoursOpen = satHoursOpen;
userContext.vars.satHoursClose = satHoursClose;
userContext.vars.sunHoursOpen = sunHoursOpen;
userContext.vars.sunHoursClose = sunHoursClose;
// continue with executing the scenario:
return done();
}