summaryrefslogtreecommitdiff
path: root/spec/frontend/__helpers__/user_mock_data_helper.js
blob: db747283d9e6cc441b18fdcba3de6fb4c05295a2 (plain)
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
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];
  },
};