debian-mirror-gitlab/spec/frontend/helpers/user_mock_data_helper.js
2020-04-22 19:07:51 +05:30

34 lines
742 B
JavaScript

let id = 1;
// Code taken from: https://gist.github.com/6174/6062387
const getRandomString = () =>
Math.random()
.toString(36)
.substring(2, 15) +
Math.random()
.toString(36)
.substring(2, 15);
const getRandomUrl = () => `https://${getRandomString()}.com/${getRandomString()}`;
export default {
createNumberRandomUsers(numberUsers) {
const users = [];
for (let i = 0; i < numberUsers; i += 1) {
users.push({
avatar_url: getRandomUrl(),
id: id + 1,
name: getRandomString(),
username: getRandomString(),
user_path: getRandomUrl(),
});
id += 1;
}
return users;
},
createRandomUser() {
return this.createNumberRandomUsers(1)[0];
},
};