Example #1
0
module.exports = function(done) {

    var data = [{
        username: faker.internet.userName(),
        email: faker.internet.email()
    }, {
        username: faker.internet.userName(),
        email: faker.internet.email()
    }];

    done(null, data);
};
    it('should be able to update saved model', function(done) {
        var username = faker.internet.userName();
        var email = faker.internet.email();

        var instance = User.new({
            username: username,
            email: email
        });

        instance
            .save(function(error, user) {
                if (error) {
                    done(error);
                } else {
                    user.username = faker.internet.userName();

                    user
                        .save(function(error, nextUser) {
                            if (error) {
                                done(error);
                            } else {
                                expect(nextUser.updatedAt).to.not.be.null;
                                done();
                            }
                        });
                }
            });
    });
Example #3
0
export function factory() {
  return {
    email: faker.internet.email(),
    username: faker.internet.userName(),
    password: faker.internet.password(),
  };
}
Example #4
0
 it('should create a user', async () => {
   const firstName= faker.name.firstName()
   const lastName = faker.name.lastName()
   const query = {
     operationName: 'Signup',
     variables: {
       newUserInput: {
         firstName,
         lastName,
         username: faker.internet.userName(firstName, lastName).toLowerCase(),
         email: faker.internet.email().toLowerCase(),
         password: faker.internet.password(),
       },
     },
     query: `mutation Signup($newUserInput: NewUserInput!) {
       signup(newUserInput: $newUserInput) {
         token
       }
     }`,
   }
   const injectOptions = {
     method: 'POST',
     url: '/graphql',
     payload: JSON.stringify(query),
   }
   const response = await server.inject(injectOptions)
   console.log('response', response.payload)
   const data = JSON.parse(response.payload).data
   console.log('data', data)
   expect(data.signup.token).not.toBeNull()
 })
Example #5
0
  it('renders without error', () => {


    let GP = {};
    GP.name = Faker.random.word();
    GP.author = Faker.internet.userName();
    GP.version = Faker.random.number();
    GP.keywords = Faker.random.words();
    GP.description = Faker.random.words();
    GP.installed = false;

    const component = renderer.create(
      <MuiThemeProvider>
        <GulpPlugin
          index={0}
          name={GP.name}
          author={GP.author}
          version={GP.version}
          description={GP.description}
          keywords={GP.keywords.split(' ')}
          onPluginSelect={() => {}}
          installed={GP.installed}
          connectDragSource={(props) => props}
        />
      </MuiThemeProvider>
    );
    let tree = component.toJSON();
    expect(tree).toMatchSnapshot();

  });
Example #6
0
 before(done => {
   app = require('../src/app')
   app.use(morgan('dev'))
   app.listen(3000, done)
   fixture = {
     username: faker.internet.userName(),
     password: faker.internet.password(),
     phone: faker.phone.phoneNumber('13#########'),
     email: faker.internet.email(),
     turbineUserId: faker.internet.userName(),
     spareUsername: faker.internet.userName(),
     sparePassword: faker.internet.password(),
     sparePhone: faker.phone.phoneNumber('13#########'),
     spareEmail: faker.internet.email()
   }
 })
    it('should be able to save a model and accept node error first callback', function(done) {
        var username = faker.internet.userName();
        // var email = faker.internet.email();

        var instance = User.new({
            username: username,
            email: email
        });

        instance
            .save(function(error, user) {
                if (error) {
                    done(error);
                } else {
                    expect(user.id).to.exist;
                    expect(user.id).to.not.be.null;

                    expect(user.createdAt).to.exist;
                    expect(user.createdAt).to.not.be.null;

                    expect(user.updatedAt).to.exist;
                    expect(user.updatedAt).to.not.be.null;
                    done();
                }
            });
    });
Example #8
0
 function user(index) {
   return {
     id: index + 1,
     name: faker.name.firstName() + ' ' + faker.name.lastName(),
     username: faker.internet.userName(),
     email: faker.internet.email(),
     address: {
       street: faker.address.streetName(),
       suite: faker.address.streetSuffix(),
       city: faker.address.city(),
       zipcode: faker.address.zipCode(),
       geo: {
         lat: faker.address.latitude(),
         lng: faker.address.longitude()
       }
     },
     phone: faker.phone.phoneNumber(),
     website: faker.internet.url(),
     company: {
       name: faker.company.companyName(),
       catchPhrase: faker.company.catchPhrase(),
       bs: faker.company.bs
     },
     role: faker.random.arrayElement(['admin', 'manager', 'guest'])
   };
 }
Example #9
0
const seedingMyMessages = () => {
  for (let i = 1; i <= 500; i += 1) {
    const message = faker.lorem.sentences();
    const listing = faker.random.number({ min: 1, max: 100 });
    const username = faker.internet.userName();
    const userId = faker.random.number(800);
    const profilePic = faker.internet.avatar();
    const date = faker.date.between('2015-01-01', '2019-04-30');
    const accuracy = faker.finance.amount(0, 5, 2);
    const communication = faker.finance.amount(0, 5, 2);
    const cleanliness = faker.finance.amount(0, 5, 2);
    const checkIn = faker.finance.amount(0, 5, 2);
    const value = faker.finance.amount(0, 5, 2);
    const location = faker.finance.amount(0, 5, 2);


    const realDate = moment(date).format('YYYY-MM-DD');
    db.query(`INSERT INTO Messages(message, user_id, username, profile_picture, listing, date, accuracy, communication, cleanliness, check_in, value, location) VALUES('${message}', ${userId}, '${username}', '${profilePic}', ${listing}, '${realDate}', ${accuracy}, ${communication}, ${cleanliness}, ${checkIn}, ${value}, ${location});`, (err, data) => {
      if (err) {
        console.log('ERROR GETTING DATA INSERTED', err);
      } else {
        console.log('SUCCESSFUL ENTRY', data);
      }
    });
  }
};
Example #10
0
// Add a User
function addUser() {
  const faker = require('faker');

  // Keep the username, we run search after the user is added
  var username = faker.internet.userName();

  var uri = 'http://' + webHost + webPort + '/user/add';
  var form = { form: {
    'fname': faker.name.firstName(),
    'lname': faker.name.lastName(),
    'username': username,
    'useremail': faker.internet.email(),
    'addstreet': faker.address.streetAddress(),
    'addcity': faker.address.city(),
    'addstate': faker.address.stateAbbr(),
    'addzip': faker.address.zipCode()
  }};

  // Don't always issue the request, some randomness
  if (Math.random() > 0.2) {
    request.post(uri, form)
      .on('response', function(response) {
        responseCount++;
        if (response.statusCode != 302) {
          console.log('*** Add User Error *** ' + response.statusCode);
          console.log(response.body);
        } else {
          search(username);
        }
    });
    requestCount++;
  }
}
    it('should be able to save a model and return promise if no callback provided', function(done) {
        var username = faker.internet.userName();
        var email = faker.internet.email();

        var instance = User.new({
            username: username,
            email: email
        });

        instance
            .save()
            .then(function(user) {
                expect(user.id).to.exist;
                expect(user.id).to.not.be.null;

                expect(user.createdAt).to.exist;
                expect(user.createdAt).to.not.be.null;

                expect(user.updatedAt).to.exist;
                expect(user.updatedAt).to.not.be.null;
                done();
            })
            .catch(function(error) {
                done(error);
            });
    });
Example #12
0
 function(next) {
     User
         .register({
             email: faker.internet.email(),
             username: faker.internet.userName(),
             password: faker.internet.password()
         }, next);
 },
const randomUser = (isIdle) => ({
  avatar: null,
  avatar_url: "https://cdn.discordapp.com/embed/avatars/0.png",
  discriminator: faker.random.uuid(),
  id: faker.random.uuid(),
  status: !isIdle ? 'online' : 'idle',
  username: faker.internet.userName()
});
Example #14
0
module.exports.newUser = (id, cb) => {
    User.create({
        _id: id,
        login: faker.internet.userName(),
        avatar: faker.internet.avatar()
    })
        .then(() => cb());
};
Example #15
0
function generateRandomUserData(userContext, events, done) {

  userContext.vars.fullname = `${Faker.name.firstName()} ${Faker.name.lastName()}`;
  userContext.vars.username = Faker.internet.userName().replace('.', '');
  userContext.vars.password = Faker.internet.password();

  return done();
}
Example #16
0
var run = function(){


  var app     = "SAMPLE_SERVICE";
  var channel = "CHANNEL_"+faker.random.number(parseInt(maxChannel));
  var userId  = faker.internet.userName();

  console.log('CHANNEL : ', address+'/node/' + app + '/' + channel);

  util.get( _host, _port, '/node/' + app + '/' + channel, function( err, data ){

    var query =
      'A='+app+'&'+
      'C='+channel+'&'+
      'U='+userId.replace(/\./g, '')+'&'+
      'D=DEVAPP&'+
      'S='+data.result.server.name+'&'+
      'DT={"user":"'+userId+'"}&'+
      'MD=CHANNEL_ONLY';
      ;

    var socketOptions ={
      transsessionPorts: ['websocket']
      ,'force new connection': true
    };

    console.log('CHANNEL : ',data.result.server.url+'/channel?'+query);

    var channelSocket = io.connect(data.result.server.url+'/channel?'+query, socketOptions);

    channelSocket.on( 'connect', function (){
      console.log(count_connected + '. connected');
      count_connected = count_connected + 1;

      setInterval(function() {
        channelSocket.emit('send', {'NM':'message', 'DT': { 'MG' : faker.lorem.sentence() } });
      }, 1000);

      //channelSocket.emit('send2', {'NM':'message', 'DT': { 'MG' : faker.lorem.sentence() } });

    });

    channelSocket.on( 'message', function( data ){
      console.log(data);
    });

    channelSocket.on( 'error', function ( data ){
      console.error(count_error+" "+data);
      count_error = count_error + 1;
    });

    channelSocket.on('disconnect', function() {
      console.log(count_disconnected + '. disconnected');
      count_disconnected = count_disconnected + 1;
    });

  });
};
  lazy.lines.map(String).forEach(function (line) {
    nbRead++;

    line = line.toString().replace(/\r$/, '');
    if (!line) {
      console.error('line %d: removed (line is empty)', nbRead);
      nbEmpty++;
      return;
    }

    var ec = logParser.parse(line);
    if (!ec) {
      console.error('line %d: removed (wrong format)', nbRead);
      nbWrong++;
      return;
    }

    if (ec.host) {
      var fakeHost = hosts[ec.host];
      if (!fakeHost) {
        fakeHost = faker.internet.ip();
        while (fakeHostsList[fakeHost]) {
          fakeHost = faker.internet.ip();
        }
        fakeHostsList[fakeHost] = ec.host;
        hosts[ec.host]          = fakeHost;
      }
      line = line.replace(ec.host, fakeHost);
    }

    if (ec.login) {
      var fakeLogin = logins[ec.login];
      if (!fakeLogin) {
        fakeLogin = faker.internet.userName().replace('\'', '').toUpperCase();
        while (fakeLoginsList[fakeLogin]) {
          fakeLogin = faker.internet.userName().replace('\'', '').toUpperCase();
        }
        fakeLoginsList[fakeLogin] = ec.login;
        logins[ec.login]          = fakeLogin;
      }
      line = line.replace(ec.login, fakeLogin);
    }

    resultStream.write(line + '\n');
  });
Example #18
0
 it('AddConsumer numbers test', function () {
   home_page.fillSignUpForm(faker.internet.userName(), 'Gt40vt14d', faker.internet.email());
   var welcome_page = home_page.welcomePage();
   var new_project_page = welcome_page.clickContinue();
   new_project_page.createNewProject();
   new_project_page.createProject('789364589734657', '09320970162334');
   var settings_page = new_project_page.getSettings();
   settings_page.addConsumer('12574981260');
 });
Example #19
0
 const createTweet = (body) => ({
   id: faker.random.uuid(),
   body,
   author: {
     username: faker.internet.userName(),
     avatar: faker.internet.avatar(),
     email: faker.internet.email()
   }
 });
Example #20
0
 generateLikes = (maxLikes = 10) => {
   const numberLikes = Math.floor(Math.random() * maxLikes) + 1;
   for (let i = 0; i <= numberLikes; i++) {
     this.likes.push({
       username: Faker.internet.userName(),
       profile_pic: Faker.internet.avatar()
     })
   }
 }
Example #21
0
 it('AddConsumer test', function () {
   home_page.fillSignUpForm(faker.internet.userName(), 'Gt40vt14d', faker.internet.email());
   var welcome_page = home_page.welcomePage();
   var new_project_page = welcome_page.clickContinue();
   new_project_page.createNewProject();
   new_project_page.createProject('testProject', 'testDescription');
   var settings_page = new_project_page.getSettings();
   settings_page.addConsumer('newConsumer');
 });
Example #22
0
/**
 * Create random user and assign to the AVA test context
 */
async function createUser(t) {
  const login = `${internet.userName()}${nanoid()}`
  const email = `${nanoid()}${internet.email()}`
  const password = internet.password()

  const user = await User.createOne({login, email, password})

  t.context.user = user
}
Example #23
0
const fakePlan = () => {
  return {
    title: faker.lorem.sentence(),
    description: faker.lorem.sentence(),
    author: {
      id: faker.random.uuid(),
      userName: faker.internet.userName(),
    },
  };
};
Example #24
0
 _.times(randInt(10, 30), function (i) { // add random users to the already defined ones in datatDefs.js
   promises.push(models.User.create({
     username: faker.internet.userName(),
     password: 'password', // so i can easily log in as any of these test users
     email: faker.internet.email(),
     rep: randInt(0, 10000)
   }).then(function (model) {
     myModels.user['random' + i] = model;
   }));
 });
Example #25
0
function fillUsers(id, callback) {
    User.register(new User({
        _id: id,
        username: faker.internet.userName(),
        email: faker.internet.email(),
        phone: faker.phone.phoneNumberFormat()
    }), faker.internet.password(), err => {
        err ? callback(err) : callback();
    });
}
Example #26
0
const _User = () => {
  return {
    username: Faker.internet.userName(),
    firstName: Faker.name.firstName(),
    lastName: Faker.name.lastName(),
    bio: Faker.lorem.paragraph(),
    email: Faker.internet.email(),
    password: Faker.internet.password()
  }
};
Example #27
0
const getUser = () => {
  const firstName= faker.name.firstName()
  const lastName = faker.name.lastName()
  return {
    firstName,
    lastName,
    username: faker.internet.userName(firstName, lastName).toLowerCase(),
    email: faker.internet.email().toLowerCase(),
    password: faker.internet.password(),
  }
}
Example #28
0
 generateComments = (maxComments = 3) => {
   const numberLikes = Math.floor(Math.random() * maxComments) + 1;
   for (let i = 0; i <= numberLikes; i++) {
     this.comments.push({
       id: Faker.random.uuid(),
       text: Faker.lorem.sentence(),
       username: Faker.internet.userName(),
       profile_pic: Faker.internet.avatar()
     })
   }
 }
 var resp = _.range(req.query.count || 10).map((i) => ({
   "created_time": ("" + Math.ceil(faker.date.recent(90).getTime() / 1000)),
   "text": helpers.randomCaption(),
   "id": ("c-" + faker.random.uuid().replace(/-/g, "")),
   "from": {
     "username": faker.internet.userName(),
     "profile_picture": faker.image.avatar(),
     "id": ("u-" + faker.random.uuid().replace(/-/g, "")),
     "full_name": faker.name.findName()
   }
 }));
loadTestUser.create = (userContext, events, done) => {
  // properties from my account schema
  userContext.vars.username = faker.internet.userName() + uuid();
  userContext.vars.email = faker.internet.email() + uuid();
  userContext.vars.password = faker.internet.password() + uuid();

  // properties from my profile schema
  userContext.vars.bio = faker.lorem.words(10) + uuid();
  userContext.vars.firstName = faker.name.firstName() + uuid();
  userContext.vars.lastName = faker.name.lastName() +  uuid();
  return done();
}