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;
};
 var FakerData = function(faker){
   this.faker = faker;
   this.randomWord = faker.internet.domainWord();
   this.username = 'fake_' + this.randomWord;
   this.username += _rand(100,9999);
   this.password = faker.internet.password();
   this.firstName = faker.name.firstName();
   this.lastName = faker.name.lastName();
   this.address1 = faker.address.streetAddress();
   this.city = faker.address.city();
   this.state = faker.address.stateAbbr();
   this.zip = '90210'// doesn't work so great for our purposes: faker.address.zipCode();
   this.phone = '6175519290';
 };
Example #3
0
    describe('#selectBucket', () => {
        var postEndpoint = makeSettingsEndpoint();
        postEndpoint.method = 'POST';
        postEndpoint.response = postEndpoint.response.result;
        // Bucket names cannot include periods
        var bucket = faker.internet.domainWord().replace('.', '');
        postEndpoint.response.bucket = bucket;
        postEndpoint.response.has_bucket = true;
        var endpoints = [
            postEndpoint,
            makeSettingsEndpoint()
        ];
        var server;
        before(() => {
            server = utils.createServer(sinon, endpoints);
        });
        after(() => {
            server.restore();
        });
        it('submits the selected bucket to the server, and updates data on success', (done) => {
            var vm = new s3NodeConfigVM('', {url: '/api/v1/12345/s3/settings/' });

            vm.updateFromData()
                .always(function() {
                    vm.selectedBucket(bucket);
                    var promise = vm.selectBucket();
                    promise.always(function() {
                        assert.equal(vm.currentBucket(), bucket);
                        done();
                    });
                });
        });
        it('alerts the user that the S3 addon does not support bucket names containing periods', (done) => {
            var vm = new s3NodeConfigVM('', {url: '/api/v1/12345/s3/settings/'});
            var spy = sinon.spy(bootbox, 'alert');
            vm.updateFromData()
                .always(function () {
                    vm.selectedBucket('pew.pew.pew');
                    vm.selectBucket();
                    assert(spy.calledOnce);
                    spy.restore();
                    done();
                });
        });
    });
app.get('/api/fake/internet', function(req, res) {
	res.json([
		{
			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()
		}
	])
});
Example #5
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 #6
0
describe('NodeCategorySettings', () => {
    var category = faker.internet.domainWord();
    var categories = [];
    for (var i = 0; i < 10; i++) {
        categories.push(faker.internet.domainWord());
    }
    var updateUrl = faker.internet.ip();
    var vm = new NodeCategorySettings(category, categories, updateUrl);
    describe('#constructor', function() {
        it('throws an error if no updateUrl is passed', () => {
            var broken = function() {
                new NodeCategorySettings(category, categories);
            };
            assert.throws(broken , vm.INSTANTIATION_ERROR_MESSAGE);
        });
        it('implements the changeMessage interface', () => {
            assert.isTrue(vm.hasOwnProperty('message'));
            assert.isTrue(vm.hasOwnProperty('messageClass'));
            assert.isTrue(Boolean(vm.changeMessage) || false);
            assert.isTrue(Boolean(vm.resetMessage) || false);
        });
    });
    describe('#updateSuccess', () => {
        var changeMessageSpy;
        before(() => {
            changeMessageSpy = sinon.spy(vm, 'changeMessage');
        });
        after(() => {
            vm.changeMessage.restore();
        });
        it('updates the message, updates the category, and sets the dirty state to false', () => {
            var newcategory = categories[0];
            vm.updateSuccess(newcategory);
            assert.calledWith(changeMessageSpy, vm.UPDATE_SUCCESS_MESSAGE, vm.MESSAGE_SUCCESS_CLASS);
            assert.equal(newcategory, vm.category());
            assert.isFalse(vm.dirty());
        });
    });
    describe('#updateError', () => {
        var changeMessageSpy;
        var ravenStub;
        before(() => {
            changeMessageSpy = sinon.spy(vm, 'changeMessage');
            ravenStub = sinon.stub(Raven, 'captureMessage');
        });
        after(() => {
            vm.changeMessage.restore();
            Raven.captureMessage.restore();
        });
        it('updates the message, and captures the error with Raven', () => {
            var error = faker.lorem.sentence();
            vm.updateError({}, error, {});
            assert.calledWith(changeMessageSpy, vm.UPDATE_ERROR_MESSAGE, vm.MESSAGE_ERROR_CLASS);
            assert.calledWith(ravenStub, vm.UPDATE_ERROR_MESSAGE_RAVEN, {
                url: updateUrl,
                textStatus: error,
                err: {}
            });
        });
    });
    describe('#updateCategory', () => {
        var server;
        var serverSpy = sinon.spy();
        var updateSuccessSpy = sinon.spy(vm, 'updateSuccess');
        before(() => {
            server = sinon.fakeServer.create();
            server.respondWith(
                'PUT',
                updateUrl,
                function(xhr) {
                    serverSpy();
                    var response = {
                        'updated_fields': JSON.parse(xhr.requestBody)
                    };
                    xhr.respond(
                        200,
                        {'Content-Type': 'application/json'},
                        JSON.stringify(response)
                    );
                }
            );
        });
        after(() => {
            server.restore();
        });
        it('sends a put to the updateUrl with the selected category, and updates the category on success', (done) => {
            var newcategory = categories[0];
            vm.selectedCategory(newcategory);
            vm.updateCategory()
                .always(function() {
                    assert.called(serverSpy);
                    assert.calledWith(updateSuccessSpy, newcategory);
                    done();
                });
            server.respond();
        });
    });
    describe('#cancelUpdateCategory', () => {
        var resetMessageSpy;
        before(() => {
            resetMessageSpy = sinon.spy(vm, 'resetMessage');
        });
        after(() => {
            vm.resetMessage.restore();
        });
        it('restores the selectedCategory to the VM\'s category, sets the dirty state to false, and resets the message', () => {
            vm.selectedCategory(categories[0]);
            vm.dirty(true);
            vm.changeMessage('Some message', 'some-class');
            vm.cancelUpdateCategory();
            assert.equal(vm.selectedCategory(), vm.category());
            assert.isFalse(vm.dirty());
            assert.called(resetMessageSpy);
        });
    });
});
Example #7
0
const site = {
  id: 'mozilla',
  profile: 'uuid',
  tag: 'custom',
  length: 12,
};
storiesOf('admin.siteItem', module)
  .add('default', () => <SiteItem site={site} onDelete={action('delete site')} />);

const sites = [
  site,
];

for (let i = 0; i < 10; i++) {
  sites.push({
    id: faker.internet.domainWord(),
    profile: 'uuid',
    tag: faker.lorem.word(),
    length: 12,
  });
}

storiesOf('admin.sites', module)
  .add('default', () => <SiteAdmin sites={sites} onDelete={action('delete site')} />);

storiesOf('admin.profileItem', module)
  .add('default', () =>
    <ProfileItem
      dispatch={action('dispatch')}
      profile={profile}
    />
Example #8
0
    function done() {
        task.done()
            .details('https://github.com/' + faker.internet.domainWord() + '/' + faker.company.bsNoun());

        return q.defer().promise;
    }
describe('ProjectSettings', () => {
    var category = faker.internet.domainWord();
    var categoryOptions = [];
    for (var i = 0; i < 10; i++) {
        categoryOptions.push(faker.internet.domainWord());
    }
    var updateUrl = faker.internet.ip();
    var vm = new ProjectSettings({category: category, categoryOptions: categoryOptions, updateUrl: updateUrl, node_id: 'nodeID'});
    describe('#constructor', function() {
        it('throws an error if no updateUrl is passed', () => {
            var broken = function() {
                new ProjectSettings({category: category, categoryOptions: categoryOptions});
            };
            assert.throws(broken , language.instantiationErrorMessage);
        });
        it('implements the changeMessage interface', () => {
            assert.isTrue(vm.hasOwnProperty('message'));
            assert.isTrue(vm.hasOwnProperty('messageClass'));
            assert.isTrue(Boolean(vm.changeMessage) || false);
            assert.isTrue(Boolean(vm.resetMessage) || false);
        });
    });
    describe('#updateError', () => {
        var changeMessageSpy;
        var ravenStub;
        before(() => {
            changeMessageSpy = sinon.spy(vm, 'changeMessage');
            ravenStub = sinon.stub(Raven, 'captureMessage');
        });
        after(() => {
            vm.changeMessage.restore();
            Raven.captureMessage.restore();
        });
        it('updates the message, and captures the error with Raven', () => {
            var error = faker.lorem.sentence();
            vm.updateError({}, error, {});
            assert.calledWith(changeMessageSpy, language.updateErrorMessage);
            assert.calledWith(ravenStub, language.updateErrorMessage, {
                url: updateUrl,
                textStatus: error,
                err: {},
            });
        });
    });
    describe('#updateAll', () => {
        var server;
        var serverSpy = sinon.spy();
        before(() => {
            server = sinon.fakeServer.create();
            server.respondWith(
                'PATCH',
                updateUrl,
                function(xhr) {
                    serverSpy();
                    xhr.respond(
                        200,
                        {'Content-Type': 'application/json'}
                    );
                }
            );
        });
        after(() => {
            server.restore();
        });
        it('sends a PATCH to the updateUrl with the settings inputs and updates them on success', (done) => {
            var newcategory = categoryOptions[0];
            vm.selectedCategory(newcategory);
            vm.title('New title');
            vm.description('New description');
            vm.requestPayload = vm.serialize();
            vm.updateAll()
                .always(function() {
                    assert.called(serverSpy);
                    done();
                });
            server.respond();
        });
    });
    describe('#cancelAll', () => {
        var resetMessageSpy;
        before(() => {
            resetMessageSpy = sinon.spy(vm, 'resetMessage');
        });
        after(() => {
            vm.resetMessage.restore();
        });
        it('restores the category, title, and description to those of the VM, and resets the message', () => {
            vm.selectedCategory(categoryOptions[0]);
            vm.changeMessage('Some message', 'some-class');
            vm.cancelAll();
            assert.equal(vm.selectedCategory(), vm.categoryPlaceholder);
            assert.equal(vm.title(), vm.titlePlaceholder);
            assert.equal(vm.description(), vm.descriptionPlaceholder);
            assert.called(resetMessageSpy);
        });
    });
});
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()
		}
	})
});
Example #11
0
 initializing: function () {
   this.pkg = require('../package.json');
   this.appname = [faker.internet.domainWord(), faker.internet.domainWord(), faker.random.number(9999)].join('-');
 },