Example #1
0
 process.nextTick(() => {
   e.emit('start');
   for (var i = 1; i <= num; i++) {
     const name = Faker.name.firstName();
     const email = Faker.internet.email();
     e.emit('running', name);
     let password = bcrypt.hashSync(Faker.internet.password(), 10);
     fakeUsers.push({
       name,
       email,
       password
     })
   }
   return (
     dt.Users()
       .insert(fakeUsers)
       .then(function(){
         e.emit('end', num);
         process.exit(0);
       })
   )
 });
Example #2
0
 member: _.times(30, function(n){
   return {
     id: n,
     name: faker.name.findName(),
     avatar: faker.internet.avatar(),
     title: faker.name.jobTitle(),
     day_start: faker.random.number({min:1, max:90}),
     day_end: faker.random.number({min:1, max:90}),
     follower: faker.random.number({min:10, max:999}),
     following: faker.random.number({min:10, max:999}),
     reviews: faker.random.number({min:10, max:999})
   }
 })
            it('instantiates a new folderPicker instance if folders have not been loaded', () => {
                var urls = vm.urls();
                urls.folders = faker.internet.ip();
                vm.urls(urls);
                var opts = $.extend({}, {
                    initialFolderPath: vm.folder().path || '',
                    filesData: vm.urls().folders
                }, vm.treebeardOptions);

                vm.loadedFolders(false);
                vm.activatePicker();
                assert.calledOnce(doActivatePickerStub);
            });
Example #4
0
 .then(([ users, networks ]) => ({
   name,
   avatar_url: faker.internet.avatar(),
   background_url: faker.image.imageUrl(),
   beta_access_code: faker.random.uuid(),
   description: faker.lorem.paragraph(),
   slug: faker.helpers.slugify(name).toLowerCase(),
   daily_digest: faker.random.boolean(),
   membership_fee: faker.random.number(),
   plan_guid: faker.random.uuid(),
   banner_url: faker.internet.url(),
   category: faker.random.uuid(),
   created_at: faker.date.past(),
   created_by_id: users[0].id,
   leader_id: users[0].id,
   welcome_message: faker.lorem.paragraph(),
   network_id: networks[0].id,
   location: faker.address.country(),
   slack_hook_url: faker.internet.url(),
   slack_team: faker.internet.url(),
   slack_configure_url: faker.internet.url()
 }))
 '03 - Checkout billing and shipping': function (browser) {
   browser = browser
     .click('.btn-go-to-payment')
     .waitForElementVisible('body.billing-and-shipping', 1000)
     .setValue('#billingFirstName', Faker.name.firstName())
     .setValue('#billingLastName', Faker.name.lastName())
     .setValue('#billingEmail', Faker.internet.email())
     .setValue('#billingPhone', Faker.phone.phoneNumber())
     .setValue('#billingAddress1', Faker.address.streetAddress())
     .setValue('#billingCity', Faker.address.streetAddress())
     .setValue('#billingCounty', Faker.address.streetAddress())
     .setValue('#billingPostcode', Faker.address.streetAddress())
     .moveToElement('body', 0, 0)
     .click('[name="sameAddress"]')
     .setValue('#shippingFirstName', Faker.name.firstName())
     .setValue('#shippingLastName', Faker.name.lastName())
     .setValue('#shippingEmail', Faker.internet.email())
     .setValue('#shippingAddress1', Faker.address.streetAddress())
     .setValue('#shippingCity', Faker.address.streetAddress())
     .setValue('#shippingCounty', Faker.address.streetAddress())
     .setValue('#shippingPostcode', Faker.address.streetAddress())
 },
Example #6
0
app.get('/api/users', function(req, res) {
    var users = [];
    var count = req.query.count && parseInt(req.query.count) || 10;
    for (var i=0; i<count; i++) {
        users.push({ name:     faker.name.findName(),
                     email:    faker.internet.email(),
                     address:  faker.address.streetAddress(),
                     bio:      faker.lorem.sentence(),
                     image:    faker.image.avatar(),
                     lastseen: faker.date.recent() });
    }
    res.json({ doc: users });
});
Example #7
0
test('The grabFromQuery for a valid query string', t => {

    t.plan(4);

    const offset = faker.random.number({min: 0, max: 1000}),
          query  = fakeQuery(),
          token  = fakeToken(query, offset),
          clock  = sinon.useFakeTimers(offset),
          user   = {
              email: faker.internet.email()
          },
          state  = {
              token: {}
          };

    const expectedActions = [
        {
            type: TOKEN_VALIDATING,
            data: token
        },
        {
            type: TOKEN_VALIDATED,
            data: token
        },
        {
            type: ACCOUNT_FETCHED,
            data: user
        },
        push('/app')
    ];

    const action   = grabFromQuery(query),
          dispatch = actual => {

              if (expectedActions.length < 1) {

                  return clock.restore();
              }

              const expected = expectedActions.shift();
              t.deepEqual(actual, expected, `Should dispatch a ${ expected.type } action.`);
          };

    Request.setGetState(() => state);

    nock('https://api.spotify.com')
        .get('/v1/me')
        .reply(200, user);

    action(dispatch);
});
Example #8
0
export function createCart(productId, variantId) {
  const product = Products.findOne(productId);
  const variant = Products.findOne(variantId);
  const user = Factory.create("user");
  const cartItem = {
    _id: Random.id(),
    productId: product._id,
    shopId: getShop()._id,
    quantity: 1,
    product,
    variants: variant,
    title: product.title
  };

  const cart = {
    shopId: getShop()._id,
    userId: user._id,
    sessionId: Random.id(),
    email: faker.internet.email(),
    items: [cartItem],
    shipping: [
      {
        _id: Random.id(),
        shopId: getShop()._id,
        address: getAddress()
      }
    ],
    billing: [
      {
        _id: Random.id(),
        shopId: getShop()._id,
        address: getAddress()
      }
    ],
    workflow: {
      status: "checkoutPayment",
      workflow: [
        "checkoutLogin",
        "checkoutAddressBook",
        "coreCheckoutShipping",
        "checkoutReview",
        "checkoutPayment"
      ]
    },
    createdAt: faker.date.past(),
    updatedAt: new Date()
  };
  const newCartId = Cart.insert(cart);
  const insertedCart = Cart.findOne(newCartId);
  return insertedCart;
}
Example #9
0
    const list = ((total, list = []) => {

        while (list.length < total) {

            list.push({
                id   : faker.random.uuid(),
                name : faker.commerce.productName(),
                cover: faker.internet.avatar()
            });
        }

        return list;

    })(faker.random.number({min: 1, max: 5}));
Example #10
0
User.remove({}, function(err) {
    var user = new User({
        username: 'lucas',
        password: 'espindola',
        email: 'espdlucas@gmail.com'
    });
    user.save(function(err, user) {
        if(err) return log.error(err);
        else log.info('New user - %s:%s',user.username,user.password);
    });

    for(var i=0; i<4; i++) {
        user = new User({
            username: faker.internet.userName(),
            password: faker.internet.password(),
            email: faker.internet.email()
        });
        user.save(function(err, user) {
            if(err) return log.error(err);
            else log.info('New user - %s:%s',user.username,user.password);
        });
    }
});
Example #11
0
 constructor() {
   this.username = (faker.name.firstName() + faker.name.lastName()).substring(0, 28);
   this.password = faker.internet.password();
   this.type = 1;
   this.nickname = (faker.name.findName()).substring(0, 18);
   this.gender = 1;
   this.birthday = faker.date.between(new Date(1960, 1, 1), new Date(1994, 1, 1));
   this.coverPhoto = {
     __type: "File",
     url: "http://ac-1qdney6b.qiniudn.com/3zLG4o0d27MsCQ0qHGRg4JUKbaXU2fiE35HdhC8j.txt",
     name: "hello.txt"
   };
   this.whatsUp = faker.lorem.sentence();
 }
Example #12
0
    it('should be able to set trackable details', function(done) {

        var trackable = User.new({
            email: email,
            username: faker.internet.userName(),
            password: faker.internet.password()
        });

        expect(trackable.track).to.exist;
        expect(trackable).to.respondTo('track');

        trackable
            .track(previousIp, function(error, trackable) {
                if (error) {
                    done(error);
                } else {
                    expect(trackable.currentSignInAt).to.not.be.null;
                    expect(trackable.currentSignInIpAddress).to.not.be.null;
                    expect(trackable.currentSignInIpAddress).to.equal(previousIp);
                    done();
                }
            });
    });
async function createNewUser(overrides) {
  const password = faker.internet.password()
  const userData = generateUserData(overrides)
  const {email, username} = userData
  const user = await api
    .post('users', {user: {email, password, username}})
    .then(getUser)
  return {
    user,
    cleanup() {
      return api.delete(`users/${user.username}`)
    },
  }
}
Example #14
0
function fakeNetwork (_, Promise) {
  const name = faker.random.words()
  const past = faker.date.past()

  return Promise.resolve({
    name,
    description: faker.lorem.paragraph(),
    avatar_url: faker.internet.avatar(),
    banner_url: faker.image.imageUrl(),
    slug: faker.helpers.slugify(name).toLowerCase(),
    created_at: past,
    updated_at: past
  })
}
Example #15
0
function generateProfile () {
  const name = {
    familyName: faker.name.lastName(),
    middleName: faker.name.firstName(),
    givenName: faker.name.firstName()
  }
  return {
    provider: 'facebook',
    id: Math.ceil(Math.random() * 1000000),
    displayName: `${name.givenName} ${name.familyName}`,
    emails: [{value: faker.internet.email()}],
    name: name
  }
}
const makeUser = (userParams = {}, ignoreDupe = false) => {
  const expectedUser = {
    firstName: faker.name.firstName(),
    lastName: faker.name.lastName(),
    email: faker.internet.exampleEmail(),
    ...userParams,
  };

  if (!ignoreDupe && emailSet.has(expectedUser.email)) {
    return makeUser(userParams);
  }
  emailSet.add(expectedUser.email);
  return expectedUser;
};
Example #17
0
module.exports.createNewFakeUsers = () => {
    var username = faker.internet.userName();
    var photo_album = path.join(process.cwd(),'profiles', username);
    var password = faker.internet.password();

    var salt = bcrypt.genSaltSync(10);
    var hash_pass = bcrypt.hashSync(password, salt);

    var firstname = faker.name.firstName();
    var lastname =  faker.name.lastName();

    var email = faker.internet.email();
    var gender = faker.random.boolean();
    var time_created = faker.date.recent();

    var last_login = faker.date.recent();
    var age = faker.random.number();
    var new_user = new User({username: username,email:email,password,hash_pass,
        name: {firstname:firstname,lastname:lastname},timeCreated:time_created, photoAlbum:photo_album,
    gender:gender,lastLogin:last_login,age:age});

    return new Promise((resolve, reject)=> {
        new_user.save((err, res) => {
            if(err){
                console.error(err);
                reject(err)
            }
            else
            {
                console.log(res);
                resolve(res);
            }
        });
    });


}
Example #18
0
gulp.task('build', ['styles'], function() {
  var fakeData = {
    fullname: faker.name.findName(),
    title: faker.name.jobTitle(),
    username: faker.name.firstName().toLowerCase(),
    password: faker.internet.password(9),
    wifi_password: faker.internet.password(9),
    fileserver_address: 'smb://' + faker.internet.domainName(),
    webmail_url: 'http://mail.' + faker.internet.domainName(),
    google_apps_url: 'http://docs.' + faker.internet.domainName()
  };

  var templateBase = gulp.src('./templates/src/welcome*.html.j2')
    .pipe(prettify());

  var template = templateBase
    .pipe(clone())
    .pipe(inlinesource({ rootpath: './templates/preview' }))
    .pipe(gulp.dest('./templates'))
    .on('data', function(data) {
      gutil.log('Generated template', chalk.cyan(data.relative));
    });

  var preview = templateBase
    .pipe(nunjucksRender({ data: fakeData }))
    .pipe(rename(function(path) {
      path.basename = path.basename.replace('welcome', 'index');
      path.extname = '';  // seems like a bug, basename still has the extension
    }))
    .pipe(gulp.dest('./templates/preview'))
    .pipe(browserSync.stream())
    .on('data', function(data) {
      gutil.log('Rendered preview template', chalk.cyan(data.relative));
    });

  return mergeStream(template, preview);
});
Example #19
0
function addRandomUser(password, done, callback)
{
	var email = faker.internet.email();
	var password = "password";
	
	membershipManager.createUser({
		email: email,
		password: password
	}).then(function(user){
		if(callback)
		{
			callback(user);
		}
	}).catch(function(error) { done(error); });
}
module.exports.generateReviews = function (amount = 3000) {
  const reviews = [];
  for (let i = 1; i < amount; i += 1) {
    const entry = {
      username: faker.internet.userName(),
      text: faker.lorem.sentences(),
      rating: Math.floor(Math.random() * 5) + 1,
      // future refactor needed to generate dynamic date
      date: new Date(),
      businessId: Math.floor(Math.random() * 100) + 1,
    };
    reviews.push(entry);
  }
  return reviews;
};
Example #21
0
var makeFakeData = function(overrides) {
    var nodeHasAuth = faker.random.number() ? true : false;
    var userHasAuth = faker.random.number() ? true : false;
    var userIsOwner = faker.random.number() ? true : false;
    var ownerName = faker.name.findName();
    var folder = {
        name: faker.hacker.noun(),
        id: faker.finance.account(),
        path: faker.hacker.noun()
    };
    var urlPath = faker.internet.domainWord();
    var url = faker.internet.ip();
    var urls = {};
    urls[urlPath] = url;
    var data = {
        nodeHasAuth: nodeHasAuth,
        userHasAuth: userHasAuth,
        userIsOwner: userIsOwner,
        folder: folder,
        ownerName: ownerName,
        urls: urls
    };
    return $.extend({}, data, overrides);
};
Example #22
0
 test.it('8.1 should add/publish api backend as a new user', function() {
     CommonUtils.signUp(driver);
     var userName = faker.internet.userName();
     while (userName.indexOf('.') > -1 || userName.indexOf('_') > -1) {
         userName = faker.internet.userName();
     }
     var email = faker.internet.email();
     newUser.added = true;
     newUser.email = email;
     CommonUtils.fillSignUpForm(driver, userName, email, faker.internet.password());
     CommonUtils.goToDashboard(driver);
     AddAPIBackendUtil.addNewBackend(driver, {
         backendName: 'NewBackend',
         description: 'Test Description',
         hostName: 'google.com',
         portNumber: '80',
         frontendPrefix: '/test',
         backendPrefix: '/test'
     });
     var publishedAPIHostElement = driver.findElement(By.xpath('//*[@class="page-title"]'));
     publishedAPIHostElement.getText().then(function(text){
         assert.equal(text, 'NewBackend');
     });
 });
Example #23
0
 it('should fail on duplicate laundry', async () => {
   const {laundry} = await dbUtils.populateLaundries(1)
   await request(app)
     .post('/users/with-laundry')
     .send({
       displayName: 'Bob',
       email: faker.internet.email(),
       password: 'password1234',
       name: laundry.model.name,
       googlePlaceId
     })
     .set('Accept', 'application/json')
     .expect('Content-Type', /json/)
     .expect(409)
 })
Example #24
0
const users = range(0, 20).map(() => {
  let name = Faker.name.firstName();
  let userName = Faker.internet.userName(name);  
  return {
    'uid': Faker.random.uuid(),
    'name': name,
    'email': Faker.internet.email(userName),
    'username': userName,
    'phone': Faker.phone.phoneNumber(),
    'avatar': Faker.image.avatar(),
    'address': {
      'street': Faker.address.streetAddress(),
      'suite': Faker.address.secondaryAddress(),
      'city': Faker.address.city(),
      'state': Faker.address.state(),
      'country': Faker.address.country(),
      'zipcode': Faker.address.zipCode(),
      'geo': {
        'lat': Faker.address.latitude(),
        'lng': Faker.address.longitude()
      }
    },    
  };
});
Example #25
0
          (function addNextTribe(tribeIndex) {
            var tribe = new Tribe();

            tribe.label = faker.lorem.word() + '_' + (tribes.length + tribeIndex);
            tribe.labelHistory = faker.random.words();
            tribe.slugHistory = faker.random.words();
            tribe.synonyms = faker.random.words();
            tribe.color = faker.internet.color().slice(1);
            tribe.count = 0;
            tribe.created = Date.now();
            tribe.modified = Date.now();
            tribe.public = true;
            tribe.image_UUID = _.sample(tribeImageUUIDs);
            tribe.attribution = faker.name.findName();
            tribe.attribution_url = faker.internet.url();
            tribe.description = faker.lorem.sentences();

            tribe.save(function (err) {
              if (err != null) {
                console.log(err);
              }
              else {
                process.stdout.write('.');
                savedTribes += 1;
                if ((limit && (savedTribes + tribes.length >= max))
                    || !limit && ((savedTribes >= max))) {
                  console.log('');
                  console.log(chalk.green(tribes.length + ' tribes existed in the database.'));
                  console.log(chalk.green(savedTribes + ' tribes successfully added.'));
                  console.log(chalk.green('Database now contains ' + (tribes.length + savedTribes) + ' tribes.'));
                  console.log(chalk.white('')); // Reset to white
                  process.exit(0);
                }
              }
            });
          }(index));
function generateChartGrid(_opts) {
	_opts = _opts || {};
	var opts = _.defaults(_opts, defaultOpts);

	var randChartProps = {
		scale: {
			primaryScale: {
				prefix: faker.finance.currencySymbol(),
				suffix: " " + faker.hacker.noun() + "s",
			}
		},
		input: {
			raw: defaultInput.init_data_ordinal,
			status: "VALID",
			valid: true
		},
		chartSettings: [],
		data: [],
		extraPadding: {
			top: 0,
			right: 0,
			bottom: 0,
			left: 0
		},
		_grid: {
			type: opts.type
		},
		numColors: 11,
		mobile: {}
	};

	var randMetadata = {
		id: null,
		chartType: "chartgrid",
		title: faker.company.catchPhrase(),
		source: "Data: " + faker.company.companyName(),
		credit: faker.address.country() + " | " + faker.internet.domainName(),
		size: opts.size
	};

	var chartProps = parseChartGrid(chartGridConfig, randChartProps);
	var anyDragged = false;

	return {
		chartProps: chartProps,
		metadata: randMetadata
	};
}
 '03 - Checkout booking info': function (browser) {
   browser = browser
     .click('.btn-go-to-payment')
     .waitForElementVisible('body.booking-info', maxWait)
     .setValue('#firstName', Faker.name.firstName())
     .setValue('#lastName', Faker.name.lastName())
     .setValue('#email', Faker.internet.email())
     .setValue('#tel', Faker.phone.phoneNumber())
     .click('[name="dietNone"]')
     .click('.btn-confirm-attendee')
     .waitForElementVisible('#modal-diet-requirements-anything button', maxWait)
     .click('#modal-diet-requirements-anything button')
     .waitForElementNotVisible('#modal-diet-requirements-anything', maxWait)
     .waitForElementVisible('.btn[href="/checkout/billing-and-shipping"]', maxWait)
     .click('.btn[href="/checkout/billing-and-shipping"]')
     .waitForElementVisible('body.billing-and-shipping', maxWait)
 },
export function getRandomUser () {
  const defaultUser = {
    name: {
      first: faker.name.firstName(),
      last: faker.name.lastName(),
    },
    email: faker.internet.email(),
    location: {
      street: faker.address.streetAddress(),
      city: faker.address.city()
    }
  };

  return new Promise((resolve, reject) => {
    resolve(defaultUser);
  });
}
Example #29
0
 handler: function (request, reply) {
     const person = {
         email: faker.internet.email(),
         firstName: faker.name.firstName(),
         lastName: faker.name.lastName(),
         findName: faker.name.findName(),
         jobTitle: faker.name.jobTitle(),
         prefix: faker.name.prefix(),
         suffix: faker.name.suffix(),
         title: faker.name.title(),
         jobDescriptor: faker.name.jobDescriptor(),
         jobArea: faker.name.jobArea(),
         jobType: faker.name.jobType()
     };
     
     reply(person);
 }
function prom(query, opts = {}) {
  if (!query) { return Promise.reject(new Error('Required parameter: "query"')); }

  let uri = baseUrl + query;
  const cfg = {
    method: 'GET',
    // To avoid blocking.
    headers: { 'User-Agent': faker.internet.userAgent() },
    json: true,
    timeout: opts.timeout || 5000,
  };

  if (opts.exploits) { uri += '&e=1'; } // default: false
  cfg.uri = uri;

  return request.get(cfg);
}