コード例 #1
0
var generarUsuario1= function(){
	var randomId=faker.random.uuid();
	var randomName=faker.name.findName();
	var randomContent=faker.lorem.sentence();
	var randomImage=faker.image.people();
	var randomDate=faker.date.past();
	var randomAddress=faker.address.streetAddress();
	return {
		ID: randomId,
		Nombre: randomName,
		Contenido: randomContent,
		Fecha: randomDate,
		Imagen: randomImage,
		Direccion: randomAddress
	}
}
コード例 #2
0
ファイル: index.js プロジェクト: whoisandie/dbmslab
var generateFriends = function(ids, user){
  var friends = [];
  for(var i=0; i< rand(ids.length/2, ids.length); i++){
    friends.push({
      friend_id: faker.random.array_element(ids),
      status: faker.random.array_element(['pending', 'accepted']),
      timestamp: faker.date.past()
    });
  }

  var friend = {
    user_id: user,
    friends: friends,
  };
  return friend;
};
コード例 #3
0
function provisionCreateEmployee() {
    var dob = faker.date.past(40, new Date('Sat Apr 01 1998 21:35:02 GMT+0200 (CEST)'));
    return {
        firstName: faker.name.firstName(),
        lastName: faker.name.lastName(),
        phone: faker.phone.phoneNumber(),

        imageUrl: faker.image.avatar(),
        jobTitle: faker.name.title(),
        department: faker.name.jobArea(),
        dateOfBirth: dob,

        address: provisionCreateAddress(),
        jobHistory: provisionCreateJobHistory(dob)
    };
}
コード例 #4
0
  mentions: function (count, options) {
    count = count || 4;
    options = options || {};

    const mentions = [];

    for (let i = 0; i < count; i++) {
      let author = !i || faker.random.number(4);
      let mention = {
        author: {
          name: author ? faker.name.findName() : null,
          photo: (!i || (author && faker.random.number(2))) ? faker.image.avatar() : null,
          url: (!i || (author && faker.random.number(3))) ? 'http://' + faker.internet.domainName() + '/' : null
        },
        name: (!i || faker.random.number(6)) ? null : faker.lorem.words(1 + faker.random.number(4)).join(' '),
        published: new Date(faker.date.recent(30)).getTime(),
        summary: faker.lorem.paragraph(),
        url: 'http://' + faker.internet.domainName() + '/' + faker.lorem.words(1 + faker.random.number(4)).join('/'),
        targets: ['http://example.com/'],
        type: 'mention',
        interactions: []
      };

      if (options.interactions === true || !faker.random.number(1)) {
        if (options.interactions === true) {
          mention.type = faker.random.array_element(['like', 'repost']);
        } else if (options.interactions === false) {
          mention.type = 'reply';
        } else {
          mention.type = faker.random.array_element(['like', 'repost', 'reply']);
        }

        let jl = faker.random.number(3) + 1;
        if (options.interactions === true || !faker.random.number(1)) {
          jl -= 1;
          mention.interactions.push('http://example.com/');
        }
        for (let j = 0; j < jl; j++) {
          mention.interactions.push('http://' + faker.internet.domainName() + '/' + faker.lorem.words(1 + faker.random.number(4)).join('/'));
        }
      }

      mentions.push(mention);
    }

    return mentions;
  }
コード例 #5
0
 () => {
   const goodsCount = faker.random.number({ min: 1, max: 25 })
   const discount = faker.random.arrayElement([0, 2.5, 5, 10, 15, 20, 25])
   const goodsLocal = _.times(goodsCount, () => ({
     ...faker.random.arrayElement(savedGoods).toJSON(),
     qty: faker.random.number({ min: 1, max: 15 }),
   }))
   return new Order(
     {
       date: faker.date.past(),
       discount,
       customer: faker.random.arrayElement(savedCustomers),
       goods: goodsLocal,
       paid: faker.random.boolean(),
     }
   )
 }
コード例 #6
0
ファイル: miserver.js プロジェクト: XtnkrR/RETO1
var generarDatos = function(){
  var randomId = faker.random.uuid();
  var randomName = faker.name.findName();
  var randomContent = faker.lorem.sentence();
  var randomDate = faker.date.recent();
  var randomImage = faker.image.avatar();
  var randomCountry = faker.address.country();
  return {
    id: randomId,
    nombre: randomName,
    contenido: randomContent,
    fecha: randomDate,
    imagen: randomImage,
    pais: randomCountry
  }

}
コード例 #7
0
app.get('/api/fake/date', function(req, res) {
	res.json([
		{
			past: faker.date.past(),
			future: faker.date.future(),
			between: faker.date.between(),
			recent: faker.date.recent(),
			month: faker.date.month(),
			weekday: faker.date.weekday()
		}
	])
});
コード例 #8
0
    it('should throw unique error message using node callback style', function(done) {

        User
            .findOrCreate({
                email: faker.internet.email()
            }, {
                email: email,
                username: username,
                birthday: faker.date.past()
            }, function(error, user) {
                expect(error.Errors.email).to.exist;

                expect(error.Errors.email[0].message)
                    .to.equal(User.validationMessages.email.unique);

                done(null, user);
            });
    });
コード例 #9
0
ファイル: faker.js プロジェクト: Rigg802/SampleApp
 createFakeRowObjectData(index) {
     return {
         id: index,
         avartar: faker.image.avatar(),
         city: faker.address.city(),
         email: faker.internet.email(),
         firstName: faker.name.firstName(),
         lastName: faker.name.lastName(),
         street: faker.address.streetName(),
         zipCode: faker.address.zipCode(),
         date: faker.date.past(),
         bs: faker.company.bs(),
         catchPhrase: faker.company.catchPhrase(),
         companyName: faker.company.companyName(),
         words: faker.lorem.words(),
         sentence: faker.lorem.sentence(),
     };
 }
コード例 #10
0
ファイル: dummy.js プロジェクト: Hylozoic/hylo-node
 .then(follows => {
   const created = faker.date.past()
   return Promise.all(
     // Add five messages to each followed thread
     [ ...follows, ...follows, ...follows, ...follows, ...follows ]
       .map(follow => {
         created.setHours(created.getHours() + 1)
         return knex('comments')
           .insert({
             text: faker.lorem.paragraph(),
             post_id: follow.post,
             user_id: follow.user,
             created_at: created.toUTCString(),
             active: true
           })
         })
     )
 })
コード例 #11
0
function createFakeRowObjectData(/*number*/ index) {
  return {
    id: 'id_' + index,
    avartar: faker.image.avatar(),
    county: faker.address.county(),
    email: faker.internet.email(),
    title: faker.name.prefix(),
    firstName: faker.name.firstName(),
    lastName: faker.name.lastName(),
    street: faker.address.streetName(),
    zipCode: faker.address.zipCode(),
    date: faker.date.past(),
    bs: faker.company.bs(),
    catchPhrase: faker.company.catchPhrase(),
    companyName: faker.company.companyName(),
    words: faker.lorem.words(),
    sentence: faker.lorem.sentence()
  };
}
コード例 #12
0
 .get('/feeds', (ctx, next) => {
   const feeds = [];
   for (let index = 1; index <= 5; index += 1) {
     const feed = {
       id: faker.random.uuid(),
       total_price: faker.finance.amount(),
       modified_date: faker.date.past(),
       winner_account: {
         profile_img_url: faker.image.avatar(),
         address: faker.finance.bitcoinAddress(),
       },
       asset: {
         name: faker.lorem.word(),
       },
     };
     feeds.push(feed);
   }
   ctx.body = feeds;
 });
コード例 #13
0
function createFakeRow(index) {
  return {
    id: index,
    avartar: faker.image.avatar(),
    county: faker.address.county(),
    email: faker.internet.email(),
    title: faker.name.prefix(),
    firstName: faker.name.firstName(),
    lastName: faker.name.lastName(),
    street: faker.address.streetName(),
    zipCode: faker.address.zipCode(),
    date: faker.date.past().toLocaleDateString(),
    jobTitle: faker.name.jobTitle(),
    catchPhrase: faker.company.catchPhrase(),
    companyName: faker.company.companyName(),
    jobArea: faker.name.jobArea(),
    jobType: faker.name.jobType()
  };
}
コード例 #14
0
ファイル: portal.js プロジェクト: uidriven/flow
 function guessValue(propertyType) {
     switch (propertyType) {
         case 'string':
             return faker.lorem.sentence();
         case 'number':
             return faker.random.number();
         case 'boolean':
             return faker.random.boolean();
         case 'object':
             return faker.random.objectElement();
         case 'array':
             return faker.random.arrayElement();
         case 'date':
             return faker.date.future();
         case 'buffer':
             return '';
         case 'geopoint':
             return '';
     }
 }
コード例 #15
0
var user = function(i) {
  var isOfficial = i%5 == 0
  return {
    userId: 'user_' + i,
    firstName: faker.name.firstName(),
    lastName: faker.name.lastName(),
    email: faker.internet.email(),
    phone: faker.phone.phoneNumber(),
    vod: {
      dimentions: {
        width: 100,
        height: 100
      },
      duration: 3600000000
    },
    createdAt: faker.date.past(),
    official: isOfficial,
    role: [''+i, ''+i*2],
  };
};
コード例 #16
0
ファイル: index.js プロジェクト: whoisandie/dbmslab
var generateUser = function(){
  var user = {
    name: faker.name.findName(),
    username: faker.internet.userName().toLowerCase(),
    email: faker.internet.email().toLowerCase(),
    phone: faker.phone.phoneNumberFormat(),
    address: {
      street: faker.address.streetAddress(),
      city: faker.address.city(),
      state: faker.address.stateAbbr(),
      zipcode: faker.address.zipCode()
    },
    education:{
      school: faker.random.array_element(schools),
      college: faker.random.array_element(colleges)
    },
    timestamp: faker.date.past()
  };
  return user;
};
コード例 #17
0
ファイル: data.js プロジェクト: dogenzaka/ng-manager
var user = function(i) {
  return {
    userId: 'user_' + i,
    firstName: faker.name.firstName(),
    lastName: faker.name.lastName(),
    email: faker.internet.email(),
    phone: faker.phone.phoneNumber(),
    vod: {
      dimentions: {
        width: 100,
        height: 100
      },
      duration: 3600000000
    },
    country: [{ key: 30, text: 'Japan' }, { key: 19, text: 'Spain' }],
    comment: "ng-manager\nExtensible management console running on angular and material design.\n\nThis project is under development.",
    userIcon: '55/14/55149073c31b4f9ab651a1b02fcdf9bd/55149073c31b4f9ab651a1b02fcdf9bd%401421660751423-400k-00001',
    createdAt: faker.date.past(),
    boolean: true
  };
};
コード例 #18
0
ファイル: ams.js プロジェクト: eshell/ams-ng2
app.get('/eventsGenerator.json', function(req, res) {
    // var eventModel = {
    //     id:'',
    //     ownerId:'',
    //     title:'',
    //     address:'',
    //     city:'',
    //     state:'',
    //     zip:'',
    //     description:'',
    //     date:'',
    //     categories:'',
    //     who:''
    // };
    var ret = [];
    for(var i=0; i<50;i++){
        // var id=faker.random.number();
        ret.push({
            "id":faker.random.number(),
            "ownerId":faker.random.number(),
            "title":faker.random.word(),
            "location":{
                "address":faker.address.streetAddress(),
                "city":faker.address.city(),
                "state":faker.address.stateAbbr(),
                "zip":faker.address.zipCode(),
                "geo":{
                    "lat":faker.address.latitude(),
                    "lng":faker.address.longitude()
                }
            },
            description:faker.lorem.paragraph(),
            date:faker.date.future(),
            categories:[1,2,3],
            who:[1,2,3]
        });
    }
    res.json(ret);
});
コード例 #19
0
ファイル: dummy.js プロジェクト: Hylozoic/hylo-node
 .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()
 }))
コード例 #20
0
ファイル: page.js プロジェクト: learn-vue/vue-demo
		fn : function(req, res, query) {

			var results = [];

			var NameArr = ['卡尔玛','潘森','卡特琳娜','安妮','布隆','艾希','盖伦','赵信','嘉文','瑞文',]

			for (var i = 0; i < query.pageSize; i++) {
				results.push({
					id : faker.random.number().toString(),// 计划ID
					advId : faker.random.number().toString(),// 广告主ID
					advName : NameArr[(faker.random.number()+'').slice(-1)],// 广告主名称
					name : faker.name.firstName(),// 计划名称
					budgetAmountTotal : faker.finance.amount(),// 计划预算
					budgetAmountDaily : faker.finance.amount(),// 计划每日预算
					verificationStatus : [ "CREATING", "PENGDING",
							"APPROVED", "DENIED" ][faker.random
							.number() % 4],// 应用审核状态
					availabilityStatus : [ "ONLINE",
										"OFFLINE_COMPLETEDONLINE",
										"OFFLINE_OUT_OF_DAILY_BUDGET",
										"OFFLINE_OUT_OF_TOTAL_BUDGET",
										"OFFLINE_UNKNOWN_EXECEPTION",
										"OFFLINE_SUSPEND" ][faker.random
							.number() % 6],// 应用审核通过以后才可能有这个状态,应用投放状态
					createdAt : faker.date.past().getTime()
				});
			}

			return {
				ret : 1,
				result : {
					pageSize : query.pageSize,
					pageNum : query.pageNum,
					totalRecords : 400,
					results : results
				}
			};
		},
コード例 #21
0
ファイル: generate.js プロジェクト: limweb/react-combo
  return function(len){

    if (cache[len]){
      return cache[len]
    }

    var arr = []

    for (var i = 0; i < len; i++){
      arr.push({
        id       : i,
        grade      : Math.round(Math.random() * 10),
        email    : faker.internet.email(),
        firstName: faker.name.firstName(),
        lastName : faker.name.lastName(),
        birthDate: faker.date.past()
      })
    }

    cache[len] = arr

    return arr
  }
コード例 #22
0
ファイル: fillDB.js プロジェクト: Lucifer-is-my-pet/team1
function fillQuests(usersId, callback) {
    var size = Math.floor(1 + Math.random() * commentsMaxCount);
    var users = [];
    for (var i = 0; i < size; i++) {
        users.push(usersId[Math.floor(Math.random() * peopleCount)]);
    }

    new Quest({
        name: faker.company.companyName(),
        author: usersId[Math.floor(Math.random() * peopleCount)],
        city: faker.address.city(),
        description: faker.hacker.phrase(),
        comments: [new Comment({
            author: usersId[Math.floor(Math.random() * peopleCount)],
            date: Date.now,
            text: faker.hacker.phrase()
        })],
        date: faker.date.past(),
        photo: new Photo({
            checkIn: users,
            link: faker.image.imageUrl(),
            description: faker.hacker.phrase(),
            hint: faker.hacker.phrase(),
            location: new Location({
                lat: faker.address.latitude(),
                lon: faker.address.longitude()
            }),
            comments: [new Comment({
                author: usersId[Math.floor(Math.random() * peopleCount)],
                date: Date.now,
                text: faker.hacker.phrase()
            })]
        })
    }).save(err => {
        err ? callback(err) : callback();
    });
}
コード例 #23
0
ファイル: page.js プロジェクト: learn-vue/vue-demo
		fn : function(req, res, query) {

			var results = [];
			for (var i = 0; i < query.pageSize; i++) {
				results.push({
					id : faker.random.number(),
					date : faker.date.past(),
					title : '[重要]' + faker.name.firstName() + ','
							+ faker.name.lastName(),
					content : '[haha]' + faker.name.firstName() + ','
							+ faker.name.lastName()
				});
			}

			return {
				ret : 1,
				result : {
					pageSize : query.pageSize,
					pageNo : query.pageNo,
					totalRecords : 400,
					results : results
				}
			};
		},
コード例 #24
0
ファイル: pictures.js プロジェクト: cyrillebonnaud/myApp
 date: () => faker.date.past(),
コード例 #25
0
    }
    return rows;
  },

  createFakeRowObjectData(index) {
    return {
      id: 'id_' + index,
      avartar: faker.image.avatar(),
      county: faker.address.county(),
      email: faker.internet.email(),
      title: faker.name.prefix(),
      firstName: faker.name.firstName(),
      lastName: faker.name.lastName(),
      street: faker.address.streetName(),
      zipCode: faker.address.zipCode(),
      date: faker.date.past().toLocaleDateString(),
      bs: faker.company.bs(),
      catchPhrase: faker.company.catchPhrase(),
      companyName: faker.company.companyName(),
      words: faker.lorem.words(),
      sentence: faker.lorem.sentence()
    };
  },

  getColumns() {
    let clonedColumns = this._columns.slice();
    clonedColumns[2].events = {
      onClick: (ev, args) => {
        const idx = args.idx;
        const rowIdx = args.rowIdx;
        this.grid.openCellEditor(rowIdx, idx);
コード例 #26
0
ファイル: sample.js プロジェクト: corncandy/wui-api
function checkETag(tag) {
  if (currentTag === tag) {
    currentTag = null;
    return true;
  } else {
    return false;
  }
}

for (var id = 0; id < 20; id++) {
  users.push({
    id: id,
    name: faker.name.findName(),
    email: faker.internet.email(),
    age: Math.floor(Math.random() * 80),
    birthday: faker.date.past(),
    status: Math.floor(Math.random() * 4)
  });
}

router.get('/users', function (req, res, next) {
  res.send({
    respHeader: {
      respCode: 'AAS-10000'
    },
    list: users,
    total: TOTAL_COUNT
  });
});

router.get('/users/:id', function (req, res, next) {
コード例 #27
0
  _generateBirthday() {
    var from = new Date(1940, 5, 7, 9, 11, 0, 0);
    var to = new Date(2000, 6, 8, 10, 12, 0, 0);

    return Faker.date.between(from, to);
  }
コード例 #28
0
ファイル: fillDB.js プロジェクト: Victoria-Vladimirova/team1
function fillQuests(usersId, callback) {
    var size = Math.floor(1 + Math.random() * commentsMaxCount);
    var users = [];
    for (var i = 0; i < size; i++) {
        users.push(usersId[Math.floor(Math.random() * peopleCount)]);
    }
    new Quest({
        name: faker.company.companyName(),
        author: usersId[Math.floor(Math.random() * peopleCount)],
        city: faker.address.city(),
        description: faker.hacker.phrase(),
        comments: [new Comment({
            author: usersId[Math.floor(Math.random() * peopleCount)],
            date: Date.now,
            text: faker.hacker.phrase()
        })],
        date: faker.date.past(),
        photo: [new Photo({
            checkIn: users,
            link: faker.image.imageUrl(),
            description: faker.hacker.phrase(),
            hint: faker.hacker.phrase(),
            location: new Location({
                lat: faker.address.latitude(),
                lon: faker.address.longitude()
            }),
            comments: [new Comment({
                author: usersId[Math.floor(Math.random() * peopleCount)],
                date: Date.now,
                text: faker.hacker.phrase()
            })]
        }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            }),
            new Photo({
                checkIn: users,
                link: faker.image.imageUrl(),
                description: faker.hacker.phrase(),
                hint: faker.hacker.phrase(),
                location: new Location({
                    lat: faker.address.latitude(),
                    lon: faker.address.longitude()
                }),
                comments: [new Comment({
                    author: usersId[Math.floor(Math.random() * peopleCount)],
                    date: Date.now,
                    text: faker.hacker.phrase()
                })]
            })],
        likes: usersId.slice(0, Math.floor(Math.random() * peopleCount / 5))
    }).save((err, quest) => {
        if (err) {
            return callback(err);
        }
        User.findByIdAndUpdate(quest.author, {
            $push: {
                ownedQuests: quest
            }
        }, callback);
    });
}
コード例 #29
0
ファイル: user.js プロジェクト: XimeraProject/server
describe('the current user', function () {
    var user = {};
    
    before(function(done){
	session
	    .get('/users/me')
            .set('Accept', 'application/json')
	    .expect(200, function(err, res) {
		user = res.body;
		done();
	    });
    });
    
    it('should include an id', function () {
	user.should.have.property('_id');
    });

    it('is available at /users/:id', function (done) {
	session
	    .get('/users/' + user['_id'])
	    .expect(200, done);
    });

    // These are really integration tests, so fuzz testing is
    // acceptable
    
    var updatedData = {
	email: faker.internet.email(),
	birthday: faker.date.past(),
	website: faker.internet.url(),
	biography: faker.lorem.text(),
	displayName: faker.name.firstName()
    };

    it('can be updated at /users/:id', function (done) {
	session
	    .post('/users/' + user['_id'])
	    .send(updatedData)
	    .expect(200, done);
    });

    it('can not be updated at by another person', function (done) {
	otherSession
	    .post('/users/' + user['_id'])
	    .send(updatedData)
	    .expect(403, done);
    });    

    it('can be retrieved a second time', function (done) {
	session
	    .get('/users/me')
            .set('Accept', 'application/json')		
	    .expect(200, function(err, res) {
		user = res.body;
		done();
	    });	
    });

    it('should include new email', function () {
	user.should.have.property('email');
	validator.normalizeEmail(user.email).should.equal( validator.normalizeEmail(updatedData.email) );
    });

    it('should include new birthday', function () {
	user.should.have.property('birthday');
	assert.deepEqual( validator.toDate(user.birthday), validator.toDate(updatedData.birthday) );
    });

    it('should include new website', function () {
	user.should.have.property('website');
	user.website.should.equal( updatedData.website );	
    });

    it('should include new biography', function () {
	user.should.have.property('biography');
	user.biography.should.equal( updatedData.biography );	
    });

    it('should include new display name', function () {
	user.should.have.property('displayName');
	user.displayName.should.equal( updatedData.displayName );	
    });                    
});
コード例 #30
0
ファイル: tageler.js プロジェクト: tageler/tageler-api
    it('/api/v1/tageler/admin/create', done => {
        // Successful creation 1
        const title = faker.lorem.word();
        const text = faker.hacker.phrase();
        const group = faker.lorem.word();
        const start = faker.date.future();
        const end = faker.date.future();
        const bringAlong = faker.lorem.word();
        const uniform = faker.lorem.word();
        const checkoutDeadline = faker.date.future();
        const checkoutContactName = faker.name.findName();
        const checkoutContactPhone = faker.phone.phoneNumber();
        const checkoutContactMail = faker.internet.email();
        const checkoutContactOther = faker.hacker.phrase();
        const free = false;

        api.post('/api/v1/tageler/admin/create')
            .send(
                {
                    title: title,
                    text: text,
                    group: group,
                    start: start,
                    end: end,
                    bringAlong: bringAlong,
                    uniform: uniform,
                    picture: picture,
                    checkout: {
                        deadline: checkoutDeadline,
                        contact: {
                            name: checkoutContactName,
                            phone: checkoutContactPhone,
                            mail: checkoutContactMail,
                            other: checkoutContactOther
                        }
                    },
                    free: free
                })
            .expect(200)
            .expect('Content-Type', /json/)
            .end((err, res) => {
                expect(res.body.success).to.equal(true);
                expect(res.body.result.title).to.equal(title);
                expect(res.body.result.text).to.equal(text);
                expect(res.body.result.group[0]).to.equal(group);
                expect(Date(res.body.result.start)).to.equal(Date(start));
                expect(Date(res.body.result.end)).to.equal(Date(end));
                expect(res.body.result.bringAlong).to.equal(bringAlong);
                expect(res.body.result.uniform).to.equal(uniform);
                expect(res.body.result.picture).to.equal(picture);
                expect(Date(res.body.result.checkout.deadline)).to.equal(Date(checkoutDeadline));
                expect(res.body.result.checkout.contact[0].name).to.equal(checkoutContactName);
                expect(res.body.result.checkout.contact[0].phone).to.equal(checkoutContactPhone);
                expect(res.body.result.checkout.contact[0].mail).to.equal(checkoutContactMail);
                expect(res.body.result.checkout.contact[0].other).to.equal(checkoutContactOther);
                expect(res.body.result.free).to.equal(free);
                tageler1 = res.body.result;
            });
        // Successful creation 2 for getTagelers unit test
        api.post('/api/v1/tageler/admin/create')
            .send(
                {
                    title: faker.lorem.word(),
                    text: faker.hacker.phrase(),
                    group: faker.lorem.word(),
                    start: faker.date.future(),
                    end: faker.date.future(),
                    bringAlong: faker.lorem.word(),
                    uniform: faker.lorem.word(),
                    picture: picture,
                    checkout: {
                        deadline: faker.date.future(),
                        contact: {
                            name: faker.name.findName(),
                            phone: faker.phone.phoneNumber(),
                            mail: faker.internet.email(),
                            other: faker.hacker.phrase()
                        }
                    },
                    free: faker.random.boolean()
                })
            .expect(200)
            .expect('Content-Type', /json/)
            .end((err, res) => {
                tageler2 = res.body.result;
                done();
            });
    });