module.exports.generateBusiness = function (amount = 100) {
  const businesses = [];
  const suffixes = ['St', 'Dr', 'Rd', 'Blvd', 'Ln', 'Ct'];
  const randomSuffix = () => suffixes[Math.floor(Math.random() * 6)];

  for (let i = 0; i < amount; i += 1) {
    const entry = {
      name: `${faker.commerce.product()} ${faker.commerce.productMaterial()} ${faker.company.companySuffix()}`,
      claimed: Math.floor(Math.random() * 2),
      // overallRating needs future refactor to generate dynamic rating
      overallRating: Math.floor(Math.random() * 5) + 1,
      // totalReviews needs future refactor to generate dynamic count
      totalReviews: Math.floor(Math.random() * 225) + 10,
      averageCost: Math.floor(Math.random() * 4) + 1,
      businessTypeOne: faker.company.catchPhraseAdjective(),
      businessTypeTwo: faker.name.jobArea(),
      addressStreet: faker.address.streetAddress(),
      addressCityStateZip: `${faker.address.city()}, ${faker.address.stateAbbr()} ${faker.address.zipCode()}`,
      addressBetween: `b/t ${faker.address.streetName()} ${randomSuffix()} & ${faker.address.streetName()} ${randomSuffix()}`,
      addressNeighborhood: faker.address.city(),
      phoneNumber: faker.phone.phoneNumber(),
      url: `${faker.lorem.word()}${faker.internet.domainWord()}.${faker.internet.domainSuffix()}`,
    };
    businesses.push(entry);
  }
  return businesses;
};
Example #2
0
function fakeItem(){
  // trying to get a more realistic distribution here
  const priceMax = faker.random.number(10) > 8 ? 5000 : 100
  const random = (odds, value) => faker.random.number(10) < odds ? value : ""
  const times = (n, func) => {
    let i = 0
    let results = ""
    while(n > i){
      results += func()
      i = i + 1
    }
    return results
  }
  return {
    id: faker.random.uuid(),
    sku: times(16, faker.random.alphaNumeric),
    title: faker.commerce.product(),
    brand: random(8, faker.company.companyName()),
    color: random(8, faker.commerce.color()),
    size: random(8, times(2, faker.random.alphaNumeric)),
    description: random(8, faker.commerce.productName()),
    percSplit: faker.random.number(100),
    price: faker.commerce.price(0, priceMax),
    printed: faker.random.boolean()
  }
}
Example #3
0
function generateData () {
  // Championships generation
  var championships = [];
  for (var i = 0; i < 10; i++) {
    championships.push({
      "id": i,
      "name": faker.commerce.product(),
      "country": {
        "name": faker.address.country()
      },
      "arjel": faker.random.boolean()
    });
  }

  // Matches generation
  var matches = [];
  for (var j = 0; j < 50; j++) {
    matches.push({
      "id": j,
      "championshipId": faker.random.arrayElement(championships).id,
      "home": faker.address.city(),
      "away": faker.address.city(),
      "date": faker.date.recent(),
      "homeOdds": generateDoubleList(10, 1.2, 1.6),
      "homeStatistics": {
        "evo": -0.4
      },
      "drawOdds": generateDoubleList(10, 2.8, 3.4),
      "drawStatistics": {
        "evo": 0.0
      },
      "awayOdds": generateDoubleList(10, 1.9, 2.5),
      "awayStatistics": {
        "evo": 0.2
      },
      "score": faker.random.number({min: 0, max: 10}) + " - " + faker.random.number({min: 0, max: 10}),
      "status": 0
    });
  }

  // Stats by championship generation
  var statsBychampionships = [];
  for (var k = 0; k < championships.length; k++) {
    statsBychampionships.push({
      "id": k,
      "homeMean": faker.finance.amount(1.2, 1.6, 2),
      "drawMean": faker.finance.amount(2.8, 3.4, 2),
      "awayMean": faker.finance.amount(1.9, 2.5, 2)
    });
  }

  return {
    "championship": championships,
    "soccermatch": matches,
    "soccermatchstats": statsBychampionships
  };
}
app.get('/api/fake/commerce', function(req, res) {
	res.json([
		{
			color: faker.commerce.color(),
			department: faker.commerce.department(),
			productName: faker.commerce.productName(),
			price: faker.commerce.price(),
			productAdjective: faker.commerce.productAdjective(),
			productMaterial: faker.commerce.productMaterial(),
			product: faker.commerce.product()
		}
	])
});
Example #5
0
 handler: function (request, reply) {
     const commerce = {
         color: faker.commerce.color(),
         department: faker.commerce.department(),
         productName: faker.commerce.productName(),
         price: faker.commerce.price(),
         productAdjective: faker.commerce.productAdjective(),
         productMaterial: faker.commerce.productMaterial(),
         product: faker.commerce.product()
     };
     
     reply(commerce);
 }
  /**
   * Generate 5 coupons
   * @param  {[type]} req [description]
   * @param  {[type]} res [description]
   * @return {[type]}     [description]
   */
  generate(req, res) {
    const coupon = new Coupon();
    const coupons = [];

    for (let i = 0; i < 5; i++) {
      coupons.push({
        name: faker.commerce.product(),
        description: faker.lorem.words(),
        price: faker.commerce.price(),
        code: this.generateCode(),
        createdAt: new Date(),
      });
    }

    coupon.collection.insert(coupons, (err, raw) => {
      if (err) res.status(400).send(err.stack);

      res.json({ status: 200, message: raw.ops });
    });
  }
Example #7
0
'use strict'

const faker = require('faker')

let count = 15
let products = []

for (let i = 0; i < count; i++) {
  products.push({
    id: faker.random.uuid(),
    type: faker.commerce.product(),
    name: faker.commerce.productName(),
    price: faker.commerce.price(),
    material: faker.commerce.productMaterial(),
    adjective: faker.commerce.productAdjective(),
    department: faker.commerce.department(),
    image: faker.image.image(),
    description: faker.lorem.paragraph()
  })
}

module.exports = products
Example #8
0
var faker = require('faker');
var product = faker.commerce.product();
var price = faker.finance.amount();

for(i = 0; i <= 10; i++) {
    console.log(faker.commerce.product());
    console.log('$' + faker.finance.amount());
}
Example #9
0
 description: FactoryGuy.generate(() => faker.commerce.product()),
  describe('a folder and a file', function () {
    let lower = {
      path: '',
      name: faker.commerce.product().toLowerCase()
    }
    let upper = {
      path: lower.path,
      name: lower.name.toUpperCase(),
      lastModification: '2015-11-13T02:03:05Z'
    }
    let child = {
      path: path.join(lower.path, lower.name),
      name: faker.commerce.color(),
      lastModification: '2015-10-12T01:02:03Z'
    }

    before(Files.deleteAll)
    before(Cozy.registerDevice)

    before('force case insensitive for local', function () {
      this.app.instanciate()
      this.app.prep.buildId = this.app.prep.buildIdHFS
    })

    before('Create the lower folder', done =>
      Files.createFolder(lower, function (_, created) {
        let fixturePath = path.join(Cozy.fixturesDir, 'chat-mignon-mod.jpg')
        return Files.uploadFile(child, fixturePath, function (_, created) {
          child.remote = {
            id: created.id,
            size: fs.statSync(fixturePath).size
          }
          done()
        })
      })
    )

    before(Cozy.fetchRemoteMetadata)

    before('Create the upper file', function (done) {
      let fixturePath = path.join(Cozy.fixturesDir, 'chat-mignon.jpg')
      return Files.uploadFile(upper, fixturePath, function (_, created) {
        upper.remote = {
          id: created.id,
          size: fs.statSync(fixturePath).size
        }
        done()
      })
    })

    before(Cozy.sync)

    after(Cozy.clean)

    it('waits a bit to resolve the conflict', done => setTimeout(done, 3500))

    it('has the two files on local', function () {
      let paths = fs.readdirSync(this.syncPath)
      paths = (Array.from(paths).filter((f) => f !== '.cozy-desktop').map((f) => f))
      paths.length.should.equal(2)
      let [file, folder] = paths
      let { size } = fs.statSync(path.join(this.syncPath, file))
      size.should.eql(upper.remote.size)
      let parts = file.split('-conflict-')
      parts.length.should.equal(2)
      parts[0].should.equal(upper.name)
      folder.should.equal(lower.name)
      let children = fs.readdirSync(path.join(this.syncPath, folder))
      children.length.should.equal(1)
      children[0].should.equal(child.name)
    })

    it('has the files on remote', done =>
      Files.getAllFolders(function (_, folders) {
        folders.length.should.equal(1)
        folders[0].should.have.properties(lower)
        return Files.getAllFiles(function (_, files) {
          files.length.should.equal(2)
          files[0]._id.should.equal(child.remote.id)
          files[0].path.should.equal(`/${child.path}`)
          files[0].name.should.equal(child.name)
          files[0].size.should.equal(child.remote.size)
          let parts = files[1].name.split('-conflict-')
          parts.length.should.equal(2)
          parts[0].should.equal(upper.name)
          files[1].path.should.equal(upper.path)
          files[1].size.should.equal(upper.remote.size)
          done()
        })
      })
    )
  })
app.get('/api/fake', function(req, res) {
	res.json({
		"address": {
			zipCode: faker.address.zipCode(),
			city: faker.address.city(),
			cityPrefix: faker.address.cityPrefix(),
			citySuffix: faker.address.citySuffix(),
			streetName: faker.address.streetName(),
			streetAddress: faker.address.streetAddress(),
			streetSuffix: faker.address.streetSuffix(),
			streetPrefix: faker.address.streetPrefix(),
			secondaryAddress: faker.address.secondaryAddress(),
			county: faker.address.county(),
			country: faker.address.country(),
			countryCode: faker.address.countryCode(),
			state: faker.address.state(),
			stateAbbr: faker.address.stateAbbr(),
			latitude: faker.address.latitude(),
			longitude: faker.address.longitude()
		},
		"commerce": {
			color: faker.commerce.color(),
			department: faker.commerce.department(),
			productName: faker.commerce.productName(),
			price: faker.commerce.price(),
			productAdjective: faker.commerce.productAdjective(),
			productMaterial: faker.commerce.productMaterial(),
			product: faker.commerce.product()
		},
		"company": {
			suffixes: faker.company.suffixes(),
			companyName: faker.company.companyName(),
			companySuffix: faker.company.companySuffix(),
			catchPhrase: faker.company.catchPhrase(),
			bs: faker.company.bs(),
			catchPhraseAdjective: faker.company.catchPhraseAdjective(),
			catchPhraseDescriptor: faker.company.catchPhraseDescriptor(),
			catchPhraseNoun: faker.company.catchPhraseNoun(),
			bsAdjective: faker.company.bsAdjective(),
			bsBuzz: faker.company.bsBuzz(),
			bsNoun: faker.company.bsNoun()
		},
		"date": {
			past: faker.date.past(),
			future: faker.date.future(),
			between: faker.date.between(),
			recent: faker.date.recent(),
			month: faker.date.month(),
			weekday: faker.date.weekday()
		},
		"finance": {
			account: faker.finance.account(),
			accountName: faker.finance.accountName(),
			mask: faker.finance.mask(),
			amount: faker.finance.amount(),
			transactionType: faker.finance.transactionType(),
			currencyCode: faker.finance.currencyCode(),
			currencyName: faker.finance.currencyName(),
			currencySymbol: faker.finance.currencySymbol(),
			bitcoinAddress: faker.finance.bitcoinAddress()
		},
		"hacker": {
			abbreviation: faker.hacker.abbreviation(),
			adjective: faker.hacker.adjective(),
			noun: faker.hacker.noun(),
			verb: faker.hacker.verb(),
			ingverb: faker.hacker.ingverb(),
			phrase: faker.hacker.phrase()
		},
		"helpers": {
			randomize: faker.helpers.randomize(),
			slugify: faker.helpers.slugify(),
			replaceSymbolWithNumber: faker.helpers.replaceSymbolWithNumber(),
			replaceSymbols: faker.helpers.replaceSymbols(),
			shuffle: faker.helpers.shuffle(),
			mustache: faker.helpers.mustache(),
			createCard: faker.helpers.createCard(),
			contextualCard: faker.helpers.contextualCard(),
			userCard: faker.helpers.userCard(),
			createTransaction: faker.helpers.createTransaction()
		},
		"image": {
			image: faker.image.image(),
			avatar: faker.image.avatar(),
			imageUrl: faker.image.imageUrl(),
			abstract: faker.image.abstract(),
			animals: faker.image.animals(),
			business: faker.image.business(),
			cats: faker.image.cats(),
			city: faker.image.city(),
			food: faker.image.food(),
			nightlife: faker.image.nightlife(),
			fashion: faker.image.fashion(),
			people: faker.image.people(),
			nature: faker.image.nature(),
			sports: faker.image.sports(),
			technics: faker.image.technics(),
			transport: faker.image.transport()
		},
		"internet": {
			avatar: faker.internet.avatar(),
			email: faker.internet.email(),
			exampleEmail: faker.internet.exampleEmail(),
			userName: faker.internet.userName(),
			protocol: faker.internet.protocol(),
			url: faker.internet.url(),
			domainName: faker.internet.domainName(),
			domainSuffix: faker.internet.domainSuffix(),
			domainWord: faker.internet.domainWord(),
			ip: faker.internet.ip(),
			userAgent: faker.internet.userAgent(),
			color: faker.internet.color(),
			mac: faker.internet.mac(),
			password: faker.internet.password()
		},
		"lorem": {
			word: faker.lorem.word(),
			words: faker.lorem.words(),
			sentence: faker.lorem.sentence(),
			sentences: faker.lorem.sentences(),
			paragraph: faker.lorem.paragraph(),
			paragraphs: faker.lorem.paragraphs(),
			text: faker.lorem.text(),
			lines: faker.lorem.lines()
		},
		"name": {
			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()
		},
		"phone": {
			phoneNumber: faker.phone.phoneNumber(),
			phoneNumberFormat: faker.phone.phoneNumberFormat(),
			phoneFormats: faker.phone.phoneFormats()
		},
		"random": {
			number: faker.random.number(),
			arrayElement: faker.random.arrayElement(),
			objectElement: faker.random.objectElement(),
			uuid: faker.random.uuid(),
			boolean: faker.random.boolean(),
			word: faker.random.word(),
			words: faker.random.words(),
			image: faker.random.image(),
			locale: faker.random.locale(),
			alphaNumeric: faker.random.alphaNumeric()
		},
		"system": {
			fileName: faker.system.fileName(),
			commonFileName: faker.system.commonFileName(),
			mimeType: faker.system.mimeType(),
			commonFileType: faker.system.commonFileType(),
			commonFileExt: faker.system.commonFileExt(),
			fileType: faker.system.fileType(),
			fileExt: faker.system.fileExt(),
			directoryPath: faker.system.directoryPath(),
			filePath: faker.system.filePath(),
			semver: faker.system.semver()
		}
	})
});