How to use rosie - 10 common examples

To help you get started, we’ve selected a few rosie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github typicode / jsonplaceholder / seed.js View on Github external
// Tables
db.posts    = []
db.comments = []
db.albums   = []
db.photos   = []
db.users    = []
db.todos    = []

// Factories
Factory.define('post')
  .sequence('id')
  .attr('title', function() {return Faker.Lorem.sentence()})
  .attr('body', function() {return Faker.Lorem.sentences(4)})

Factory.define('comment')
  .sequence('id')
  .attr('name', function() {return Faker.Lorem.sentence()})
  .attr('email', function() {return Faker.Internet.email()})
  .attr('body', function() {return Faker.Lorem.sentences(4)})

Factory.define('album')
  .sequence('id')
  .attr('title', function() {return Faker.Lorem.sentence()})

Factory.define('photo')
  .sequence('id')
  .attr('title', function() {return Faker.Lorem.sentence()})
  .option('color', hex())
  .attr('url', [ 'color' ], function(color) {
    return 'http://placehold.it/600/' + color
  })
github typicode / jsonplaceholder / seed.js View on Github external
Factory.define('album')
  .sequence('id')
  .attr('title', function() {return Faker.Lorem.sentence()})

Factory.define('photo')
  .sequence('id')
  .attr('title', function() {return Faker.Lorem.sentence()})
  .option('color', hex())
  .attr('url', [ 'color' ], function(color) {
    return 'http://placehold.it/600/' + color
  })
  .attr('thumbnailUrl', [ 'color' ], function(color) {
    return 'http://placehold.it/150/' + color
  })

Factory.define('todo')
  .sequence('id')
  .attr('title', function() {return Faker.Lorem.sentence()})
  .attr('completed', function() { return _.random(1) ? true : false})

Factory.define('user')
  .sequence('id')
  .after(function(user) {
    var card = Faker.Helpers.userCard()
    _.each(card, function(value, key) {
      user[key] = value
    })
  })

// Has many relationships
// Users
_(10).times(function () {
github typicode / jsonplaceholder / seed.js View on Github external
_(10).times(function () {
  var user = Factory.build('user') 
  db.users.push(user)

  // Posts
  _(10).times(function() {
    // userId not set in create so that it appears as the last
    // attribute
    var post = Factory.build('post', {userId: user.id})
    db.posts.push(post)
    
    // Comments
    _(5).times(function () {
      var comment = Factory.build('comment', {postId: post.id})
      db.comments.push(comment)
    })
  })
github typicode / jsonplaceholder / seed.js View on Github external
_(10).times(function() {
    var album = Factory.build('album', {userId: user.id})
    db.albums.push(album)

    // Photos
    _(50).times(function() {
      var photo = Factory.build('photo', {albumId: album.id})
      db.photos.push(photo)
    })
  })
github typicode / jsonplaceholder / seed.js View on Github external
_(10).times(function() {
    // userId not set in create so that it appears as the last
    // attribute
    var post = Factory.build('post', {userId: user.id})
    db.posts.push(post)
    
    // Comments
    _(5).times(function () {
      var comment = Factory.build('comment', {postId: post.id})
      db.comments.push(comment)
    })
  })
github onap / sdc / openecomp-ui / test-utils / factories / common / CurrentScreenFactory.js View on Github external
Factory.define('InitializedCurrentScreenFactory')
	.option('isCertified', false)
	.option('inMerge', false)
	.option('isCollaborator', true)
	.option('isArchived', false)
	.option('isReadOnlyMode', ['isCertified', 'inMerge', 'isCollaborator', 'isArchived'], (isCertified, inMerge, isCollaborator, isArchived) =>
		isCertified || inMerge || !isCollaborator
	)
	.attr('itemPermission', ['isCertified', 'inMerge', 'isCollaborator'], (isCertified, inMerge, isCollaborator) =>
		InitializedItemPermissionFactory.build({isCollaborator, isCertified, inMerge})
	)
	.attr('props', ['isReadOnlyMode'], (isReadOnlyMode) => {
		return {isReadOnlyMode};
	});
export const InitializedCurrentScreenFactory = new Factory().extend('InitializedCurrentScreenFactory');


Factory.define('CurrentScreenFactory')
	.extend('InitializedCurrentScreenFactory')
	.option('isDirty', false)
	.option('isOutOfSync', false)
	.option('isUpToDate', true)
	.option('version', ['isCertified'], (isCertified) => VersionFactory.build({isCertified}))
	.attr('itemPermission', [
		'isCertified', 'inMerge', 'isCollaborator', 'isDirty', 'isOutOfSync', 'isUpToDate', 'isArchived'
	], (isCertified, inMerge, isCollaborator, isDirty, isOutOfSync, isUpToDate, isArchived) =>
		ItemPermissionFactory.build({isCollaborator, isCertified, inMerge, isDirty, isOutOfSync, isUpToDate, isArchived})
	)
	.attr('props', ['isReadOnlyMode', 'version'], (isReadOnlyMode, version) => {
		return {isReadOnlyMode, version};
	});
github onap / sdc / openecomp-ui / test-utils / factories / softwareProduct / SoftwareProductValidationResultsFactory.js View on Github external
*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { Factory } from 'rosie';

export const VSPTestResultsFailureFactory = new Factory().attrs({
    vspTestResults: [
        {
            scenario: 'certification',
            description: 'Other Certifications',
            testCaseName: 'certification.certificationtests.certquery',
            testSuiteName: 'certificationtests',
            executionId: 'ebaa5f21-ed68-4098-97a9-775ac8800f09-1550575025614',
            parameters: {
                vspId: 'uuidval',
                vspVersion: 'ver',
                other: 'values'
            },
            results: {
                UnknownObject: {
                    someKeyanotherobject2: 'someValue',
                    someKey1: 'someValue',
github onap / sdc / openecomp-ui / test-utils / factories / softwareProduct / SoftwareProductComponentsComputeFactory.js View on Github external
export const ComputeFlavorBaseData = new Factory()
	.attrs({
		name: () => randomstring.generate(),
		description: () => randomstring.generate(),
		id: randomstring.generate()
	});

export const ComponentComputeFactory = new Factory()
	.attrs({
		computesList: [],
		computeEditor: {}
	});


export const VSPComponentsComputeDataMapFactory = new Factory()
	.attrs({
		'vmSizing/numOfCPUs' : 3,
		'vmSizing/fileSystemSizeGB': 888,
		'numOfVMs/minimum':2
	});
github onap / sdc / openecomp-ui / test-utils / factories / licenseModel / LicenseKeyGroupFactories.js View on Github external
export const LicenseKeyGroupListItemFactory = new Factory()
    .extend('LicenseKeyGroupBaseFactory')
    .attrs({
        id: () => Math.floor(Math.random() * (1000 - 1) + 1),
        versionUUID: () => Math.floor(Math.random() * (1000 - 1) + 1),
        itemType: overviewEditorHeaders.LICENSE_KEY_GROUP
    });

export const LicenseKeyGroupStoreFactory = new Factory()
    .extend('LicenseKeyGroupBaseFactory')
    .attrs({
        id: () => Math.floor(Math.random() * (1000 - 1) + 1),
        referencingFeatureGroups: []
    });

export const LicenseKeyGroupDataListFactory = new Factory()
    .extend('LicenseKeyGroupBaseFactory')
    .attrs({
        id: () => Math.floor(Math.random() * (1000 - 1) + 1),
        referencingFeatureGroups: [],
        itemType: overviewEditorHeaders.LICENSE_KEY_GROUP
    });

export const LicenseKeyGroupPostFactory = new Factory().extend(
    'LicenseKeyGroupBaseFactory'
);
github onap / sdc / openecomp-ui / test-utils / factories / softwareProduct / SoftwareProductEditorFactories.js View on Github external
Factory.define('LicensingDataMixin')
	.attrs({
		licensingData: {
			licenseAgreement: () => randomstring.generate(33),
			featureGroups: [
				() => randomstring.generate(33)
			]
		}
	});

export const VSPEditorFactory = new Factory()
	.extend('VSPBaseFactory')
	.extend(IdMixin);

export const VSPEditorPostFactory = new Factory()
	.extend('VSPBaseFactory');

export const VSPEditorFactoryWithLicensingData = new Factory()
	.extend('VSPBaseFactory')
	.extend('LicensingDataMixin')
	.extend(IdMixin);

export const VSPEditorPostFactoryWithLicensingData = new Factory()
	.extend('VSPBaseFactory')
	.extend('LicensingDataMixin');

rosie

factory for building JavaScript objects, mostly useful for setting up test data. Inspired by factory_girl

MIT
Latest version published 6 months ago

Package Health Score

76 / 100
Full package analysis