How to use the faker.random function in faker

To help you get started, we’ve selected a few faker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Paqmind / react-ultimate / backend / helpers.js View on Github external
export function generateRobot(override) {
  // no support to pick name by gender for now in Faker :(
  return Object.assign({
    id: Faker.random.uuid(),
    name: Faker.name.firstName(),
    assemblyDate: Faker.date.between("1970-01-01", "1995-01-01"),
    manufacturer: Faker.random.array_element(["Russia", "USA", "China"]),
  }, override);
}
github tarantx / tarant / test / actor-system / actor-proxy.spec.ts View on Github external
it('should return a promise that fails and push the message to the mailbox if fails', async () => {
      const mailbox = new Mailbox()
      const actorId = faker.random.uuid()
      const methodName = faker.random.uuid()
      const resultMessage = faker.random.uuid()
      const expectedResult = faker.random.uuid()
      const args = [faker.random.uuid(), faker.random.uuid()]

      actorMessageMock.of.mockImplementation((_, __, ___, reject) => {
        reject(expectedResult)
      })
      messageMock.of.mockReturnValue(resultMessage)

      try {
        await ActorProxy.sendAndReturn(mailbox, actorId, methodName, args)
        fail()
      } catch (_) {
        //
      }
github puzzle-js / puzzle-js / tests / lib / variables.spec.ts View on Github external
it('should print variables', function () {
        const variable = faker.helpers.userCard();
        const fragmentName = faker.random.word();
        const fn = sinon.stub(Util, 'log');
        window.__fragment_variable = variable;

        Variables.set(fragmentName, '__fragment_variable', variable);
        Variables.print();

        expect(fn.calledWith(variable)).to.true;
    });
github davellanedam / node-express-mongodb-jwt-rest-api-skeleton / test / users.js View on Github external
it('it should NOT POST a user with email that already exists', done => {
      const user = {
        name: faker.random.words(),
        email,
        password: faker.random.words(),
        role: 'admin'
      }
      chai
        .request(server)
        .post('/users')
        .set('Authorization', `Bearer ${token}`)
        .send(user)
        .end((err, res) => {
          res.should.have.status(422)
          res.body.should.be.a('object')
          res.body.should.have.property('errors')
          done()
        })
    })
    it('it should NOT POST a user with not known role', done => {
github smollweide / node-mock-server / test / expected / dto-response-func / ResponseFuncTestDTO.js View on Github external
found1 = loopArr.indexOf('importedResponseFuncTestDTO');

        if (found1 >= 0) {
        	if (loopArr.indexOf('importedResponseFuncTestDTO', found1 + 1) >= 0) {
        		return '{}';
        	}
        }

        loopArr.push('importedResponseFuncTestDTO');

		return JSON.stringify({
  "list": _getArray(function () {return {  "country": _getRes('CountryWsDTO', loopArr),  "email": faker.internet.email()};}),
  "items": _getArray(function () {return _getRes('CountryWsDTO', loopArr);}),
  "image": _getRes('CountryWsDTO', loopArr),
  "exampleString": faker.lorem.word(),
  "exampleNumber": faker.random.number(),
  "exampleInteger": faker.random.number(),
  "name": faker.name.findName(),
  "firstName": faker.name.firstName(),
  "lastName": faker.name.lastName(),
  "country": _getRes('CountryWsDTO', loopArr),
  "countryIsocode": faker.random.arrayElement(["CH","DE","AT","FR","UK","US","JP"]),
  "email": faker.internet.email(),
  "phone": faker.phone.phoneNumber(),
  "postalCode": faker.address.zipCode(),
  "streetName": faker.address.streetName(),
  "streetNumber": faker.random.number(),
  "title": faker.name.prefix(),
  "titleCode": faker.random.arrayElement(["mr","ms"]),
  "town": faker.address.city(),
  "parameters": {
    "additional": faker.lorem.word()
github gkozlenko / node-video-lib / test / support / movie.js View on Github external
before(function () {
                let fragmentList = FragmentListBuilder.build(this.movie, faker.random.number({min: 3, max: 10}));
                this.fragment = fragmentList.get(faker.random.number({min: 0, max: fragmentList.count() - 1}));
            });
github sid88in / serverless-appsync-plugin / elasticsearch / seed-data / create-seed-data.js View on Github external
let numPosts = 25;

//{"index":{"_index":"user","_type":"profile","_id":"8144e3da-7521-4787-a95b-30f4081cd72e"}}

data = [];
const file = 'users.json';

for (let i = 0; i < numRecords; i++) {
  record = {
    name: faker.name.findName(),
    screen_name: faker.internet.userName(),
    location: faker.address.city(),
    description: faker.name.jobTitle(),
    followers_count: faker.random.number(),
    friends_count: faker.random.number(),
    favourites_count: faker.random.number(),
  };

  for (let j = 0; j < numPosts; j++) {
    let info = {
      _index: 'user',
      _type: 'twitter',
      _id: uuidv4(),
    };

    let item = {
      index: info,
    };

    record.tweet = faker.lorem.sentence();

    console.log(JSON.stringify(item));
github praneetrohida / Twitter-Clone / generate.js View on Github external
tweets: _.times(30, function(index) {
      return {
        id: index,
        user: {
          name: faker.name.findName(),
          username: faker.internet.userName(),
          avatar: faker.image.avatar(),
          cover: faker.image.image(),
          bio: faker.lorem.sentence(),
          location: faker.address.city(),
          following: faker.random.number(1000),
          followers: faker.random.number(10000)
        },
        time: faker.date.recent(10),
        tweetContent: faker.lorem.sentences(2),
        likes: faker.random.number(500),
        retweets: faker.random.number(500),
        replies: faker.random.number(500)
      };
    }),
    userTweets: _.times(20, function(index) {
github bmcmahen / sancho / src / stories / InfiniteScroll.stories.tsx View on Github external
function getUser() {
  faker.seed(0);

  return {
    name: faker.name.firstName() + " " + faker.name.lastName(),
    uid: faker.random.uuid(),
    description: faker.lorem.sentence()
  };
}
github jurkian / react-bank / api / util / dummy-data.js View on Github external
const createMessage = user => {
   const message = new Message({
      title: faker.lorem.words(5),
      sentDate: faker.date.between('2020-01-01', '2020-12-31'),
      recipient: user._id,
      content: faker.lorem.paragraph(),
      isRead: faker.random.boolean()
   });

   return message.save();
};