Example #1
1
export default function makeMonster(data={}) {
  return Monster(merge({
    id: UUID.v4(),
    name: Faker.name.findName(),
    citizenship: Faker.random.arrayElement(["Russia", "USA", "China"]),
    birthDate: Faker.date.between("1970-01-01", "1995-01-01"),
  }, data));
}
function createStudents() {
	var students = [];

	for ( var i = 0; i < faker.random.number(100) + 25; i++ ) {
		var gender = ( faker.random.boolean() ) ? 'women' : 'men';

		var student = {
			id: faker.random.uuid(),
			name: faker.fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'),
			image: createPortraitImageUrl(gender)
		};

		students.push(student);
	}

	return students;
}
Example #3
0
 const data = (startDays, endDays) => {
   return {
     title: `${faker.lorem.words(1)} ${faker.random.number(10)}`,
     startDate: addDays(beginning, startDays - 1),
     endDate: addDays(beginning, endDays - 1).endOf('day'),
     allDay: true
   };
 };
Example #4
0
function fakeConsignor(){
  return {
    id: faker.random.uuid(),
    firstName: faker.name.firstName(),
    lastName: faker.name.lastName(),
    company: faker.random.number(10) > 7 ? faker.company.companyName() : "",
    isStoreAccount: faker.random.boolean(),
    defaultPercSplit: faker.random.number(100),
    address: faker.address.streetAddress(),
    address2: faker.address.secondaryAddress(),
    city: faker.address.city(),
    state: faker.address.stateAbbr(),
    zip: faker.address.zipCode(),
    email: faker.internet.email(),
    items: []
  }
}
const message = (props) => Object.assign({
  from: `${faker.name.firstName()} ${faker.name.lastName()}`,
  fromAvatar: faker.image.avatar(),
  subject: faker.company.catchPhrase(),
  body: fakeBody(),
  flagged: faker.random.boolean(),
  sent: faker.date.past(1).toISOString(),
}, props);
    it('can search numbers', function(client) {
      homePage.navigate()
        .waitForElementVisible('@body')
        .setValue('@searchField', faker.random.number())
        .click('@searchButton');

      resultsPage.expect.element('@firstResultTitle').to.be.visible;
    });
Example #7
0
function generateFakePlayer() {
    return {
				version: 0,
        name: faker.name.findName(),
        effortLevel: randomNum(),
        invitedNextWeek: faker.random.boolean()
    }
}
Example #8
0
const generateUser = () => {
	return {
		uuid: Faker.random.uuid(),
		firstName: fake('{{name.firstName}}'),
		lastName: fake('{{name.lastName}}'),
		dateOfBirth: fake('{{date.past}}')
	};
}
Example #9
0
function maybe( chance, fn ) {
  var n = ( Faker.random.number( chance ) );
  if ( n === 0 ) {
    fn();
  } else {
    return false;
  }
}
Example #10
0
exports.getThirdPartyUser = function () {
    const thirdPartyUser = _.clone(exports.getLocalUser());
    thirdPartyUser.authType = 'vkontakte';
    thirdPartyUser.thirdPartyProfileUrl = faker.internet.url();
    thirdPartyUser.thirdPartyId = faker.random.number().toString();
    delete thirdPartyUser.passwordHash;
    return thirdPartyUser;
};
Example #11
0
File: Vote.js Project: tanglx61/db
exports.populate = function(opts, callback) {
	console.time('populateNotifications');

	var isPost = opts.isPost;

	var c = opts.count;
	var defaultVoteCount = isPost ? config.votes.posts : config.votes.comments;
	var count = (c && Number(c))  || defaultVoteCount;

	bar.init(count);

	if (isPost) {
		console.info('populating ' + count + ' PostVotes');
	} else {
		console.info('populating ' + count + ' CommentVotes');
	}
	

	var votes = [];


	for (var i=0; i<count; i++) {
		var vote = {
			uid: faker.random.number({min:1, max:config.users}),
			vote: faker.random.number({min:0, max:100}) < 90 ? 1 : -1
		};


		if (isPost) {
			vote.pid = faker.random.number({min:1, max:config.posts});
		} else {
			vote.cid = faker.random.number({min:1, max:config.comments});
		}

		votes.push(vote);
	}


	async.eachSeries(votes, function(vote, next){
		bar.tick();
		create({db: opts.db, vote: vote}, next);
	}, function(err){
		console.timeEnd('populateNotifications');
		if (callback) callback(err);
	});
};	
Example #12
0
    it("returns false when user is authorized and does not have intermal email", function() {
        var user = {
            id: faker.random.uuid(),
            email: faker.internet.email()
        };

        assert.equal(false, skipAnalytics(user), "skipAnalytics should return false when user is authorized and does not have internal email");
    });
function generateSessions(speakers, roomInfos) {
    var sessionList = [];
    var idSeed = 1000;
    for (var _i = 0, conferenceDays_1 = static_data_1.conferenceDays; _i < conferenceDays_1.length; _i++) {
        var confDay = conferenceDays_1[_i];
        var timeSlots = generateTimeSlots(confDay);
        for (var _a = 0, timeSlots_1 = timeSlots; _a < timeSlots_1.length; _a++) {
            var confTimeSlot = timeSlots_1[_a];
            if (confTimeSlot.isBreak) {
                var s = {
                    id: (idSeed++).toString(),
                    title: toTitleCase(confTimeSlot.title),
                    isBreak: true,
                    start: confTimeSlot.start.toString(),
                    end: confTimeSlot.end.toString(),
                    room: '',
                    roomInfo: null,
                    speakers: [],
                    description: '',
                    descriptionShort: '',
                    calendarEventId: ''
                };
                sessionList.push(s);
            }
            else {
                var subSpeakers = getRandomArrayElements(speakers, faker.random.number(3));
                var roomInfo = roomInfos[faker.random.number(roomInfos.length - 1)];
                var s = {
                    id: (idSeed++).toString(),
                    title: toTitleCase(faker.company.bs()),
                    isBreak: false,
                    start: confTimeSlot.start.toString(),
                    end: confTimeSlot.end.toString(),
                    room: roomInfo.name,
                    roomInfo: roomInfo,
                    speakers: subSpeakers,
                    description: faker.lorem.paragraph(),
                    descriptionShort: faker.lorem.sentence(),
                    calendarEventId: faker.random.uuid()
                };
                sessionList.push(s);
            }
        }
    }
    return sessionList;
}
Example #14
0
    it("returns false when user does not have an internal test name and no email", function() {
        var user = {
            id: faker.random.uuid(),
            name: faker.name.firstName()
        };

        assert.equal(false, skipAnalytics(user), "skipAnalytics should return false when user does not have an internal test name and no email");
    });
Example #15
0
function fillCharacteristics() {
    var charac = [];
    for (var i = 0; i < 10; i++) {
        charac.push(faker.random.word());
    }
    return charac;

}
function mvFromOutside() {
  if (outsidePaths.length === 0) {
    return mvToOutside()
  }
  const src = faker.random.arrayElement(outsidePaths)
  const dst = newPath()
  return { op: 'mv', from: src, to: dst }
}
Example #17
0
function randomNum(min, max) {
    min = min || 0;
    max = max || 10;
    return faker.random.number({
        "min": min,
        "max": max
    });
}
 beforeEach(inject(function () {
   context.createDirective           = createDirective;
   context.controllerUpdateFuncName  = 'editUniqueId';
   context.modalInputFuncName        = 'text';
   context.participantUpdateFuncName = 'updateUniqueId';
   context.participant               = this.participant;
   context.newValue                  = faker.random.word();
 }));
Example #19
0
var kittyData = _.map(kittyPics, function(kittyPic) {
    var kitty = {
        id: ++id,
        filename: kittyPic,
        name: Faker.Name.firstName(),
        upvotes: Faker.random.number(10),
        downvotes: Faker.random.number(10),
        catchphrase: Faker.Company.catchPhrase(),
        comments: []
    };

    for(var i = 0; i < Faker.random.number(10); i++) {
        kitty.comments.push(Faker.Lorem.sentences(Faker.random.number(5) || 1));
    }

    return kitty;
});
 before(() => {
   routes = _.range(4);
   store = faker.random.uuid();
   browserHistoryListen = (callback) => callback(faker.random.uuid());
   Module.__Rewire__('browserHistory', {
     listen: browserHistoryListen,
   });
 });
Example #21
0
 _.range(3,53).forEach(function(i) {
     const auth = {
         client_token: faker.random.uuid(),
         lease_duration: ms('30m') / 1000
     };
     args.push([null, auth]);
     stub.onCall(i).yieldsAsync(null, auth);
 });
function init(ops) {
  const n = faker.random.number(nbInitOps)
  for (let i = 0; i < n; i++) {
    const op = freq([[1, createNewDir], [1, createNewFile]])
    ops.push(op)
  }
  ops.push({ op: 'mkdir', path: '../outside' })
}
Example #23
0
exports.getTodo = (id) => {
  return {
    userId: parseInt(id / 20) + 1,
    id: id + 1,
    title: faker.lorem.text(),
    completed: faker.random.boolean(),
  };
};
Example #24
0
    it("returns true when user has an internal test name and no email", function() {
        var user = {
            id: faker.random.uuid(),
            name: "c9test07"
        };

        assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user has an internal test name and no email");
    });
Example #25
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":"******"}&'+
      '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;
    });

  });
};
Example #26
0
function getFakeDefects(quantity, users, runs, projects) {
    var defects = [];
    var priorities = ['Critical', 'Low', 'High', 'Normal'];
    var status = ['open', 'inProgress', 'notFix', 'closed'];
    for (var i = 0; i < quantity; i++) {
        defects[i] = {
            name: faker.lorem.sentence(1, 1).slice(0, -1),
            reporter: users[faker.random.number(users.length - 1)]._id,
            date: faker.date.past(),
            priority: priorities[faker.random.number(priorities.length - 1)],
            description: faker.lorem.sentence(),
            status: status[faker.random.number(status.length - 1)],
            stepsToReproduce: getStepsToReproduce(faker.random.number({min: 2, max: 10})),
            run: runs[faker.random.number(runs.length - 1)]._id,
            project: projects[faker.random.number(projects.length - 1)]._id
        };

        //if (faker.random.boolean()) {
        defects[i].assignedTo = users[faker.random.number(users.length - 1)]._id;
        //}
    }

    function getStepsToReproduce(quantity) {
        var steps = [];

        for (var i = 1; i <= quantity; i++) {
            steps[i] = i + '. ' + faker.lorem.sentence();
        }

        return steps;
    }

    return defects;
}
function createCourses(students, teachers) {
	var courses = [];

	for ( var i = 0; i < faker.random.number(50) + 15; i++ ) {
		var likes = faker.random.number(100);
		var liked = ( likes > 0 ) ? faker.random.boolean() : false;

		var enrolls = faker.random.number(100);
		var enrolled = ( enrolls > 0 ) ? faker.random.boolean() : false;

		var course = {
			id: faker.random.uuid(),
			title: faker.lorem.sentence(2),
			subtitle: faker.lorem.sentence(),
			content: truncate(faker.lorem.paragraphs(faker.random.number(2) + 1), 65),
			author: faker.fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'), //todo: deprecate in favor of teacher
			image: faker.image.image(340, 150, true),
			likes: likes, //todo: link with students faker data
			liked: liked,
			enrolls: enrolls, //todo: link with students faker data
			enrolled: enrolled
		};

		courses.push(course);
	}

	return courses;
}
Example #28
0
const videoBaseFieldValues = () => ({
  title: faker.lorem.sentence(),
  description: faker.lorem.paragraph(),
  publishedDate: faker.date.past(),
  thumbnail: 'https://unsplash.it/300/400?random',
  category: faker.lorem.word(),
  slug: faker.helpers.slugify(faker.lorem.sentence()),
  length: faker.random.number(),
});
Example #29
0
export default function () {
  /**
   * Tag Factory
   * @summary define tag Factory
   */
  Factory.define("tag", Tags, {
    name: "Tag",
    slug: "tag",
    position: _.random(0, 100000),
    //  relatedTagIds: [],
    isTopLevel: true,
    shopId: getShop()._id,
    createdAt: faker.date.past(),
    updatedAt: new Date()
  });

  /**
   * Product factory
   * @summary define product Factory
   */
  const base = {
    ancestors: [],
    shopId: getShop()._id
  };

  const priceRange = {
    range: "1.00 - 12.99",
    min: 1.00,
    max: 12.99
  };

  let product = {
    title: faker.commerce.productName(),
    pageTitle: faker.lorem.sentence(),
    description: faker.lorem.paragraph(),
    type: "simple",
    vendor: faker.company.companyName(),
    price: priceRange,
    isLowQuantity: false,
    isSoldOut: false,
    isBackorder: false,
    metafields: [],
    requiresShipping: true,
    // parcel: ?,
    hashtags: [],
    isVisible: faker.random.boolean(),
    publishedAt: new Date(),
    createdAt: new Date(),
    updatedAt: new Date()
  };

  Factory.define("product", Products, Object.assign({}, base, product));

  Factory.define("variant", Products, {
    type: "variant"
  });
}
 beforeEach(() => {
   Component = fetchDataEnhancer(callback)(Handler);
   store = { data: faker.random.uuid() };
   component = mount(
     <Provider store={store}>
       <Component message="Hello world" />
     </Provider>
   );
 });