How to use the rosie.Factory.build function in rosie

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
_(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 zooniverse / front-end-monorepo / packages / lib-classifier / src / components / Classifier / components / SubjectViewer / components / LightCurveViewer / LightCurveViewerContainer.spec.js View on Github external
const mockData = kepler

const subject = Factory.build('subject', { locations: [
  { 'application/json': 'http://localhost:8080/mockData.json' }
] })

const nextSubject = Factory.build('subject', { locations: [
  { 'text/plain': 'http://localhost:8080/nextSubject.json' }
] })

const nextSubjectJSON = { x: [1, 2], y: [3, 4] }

const imageSubject = Factory.build('subject')

const failSubject = Factory.build('subject', {
  locations: [
    { 'application/json': 'http://localhost:8080/failure.json' }
  ]
})

describe('Component > LightCurveViewerContainer', function () {
  it('should render without crashing', function () {
    wrapper = shallow( {}} setOnPan={() => {}} setOnZoom={() => {}} />)
    expect(wrapper).to.be.ok()
  })

  it('should mount with an initialized state', function () {
    wrapper = shallow(
       { }} setOnPan={() => { }} setOnZoom={() => { }} />,
      { disableLifecycleMethods: true }
    )
github zooniverse / front-end-monorepo / packages / lib-classifier / src / components / Classifier / components / MetaTools / MetaTools.spec.js View on Github external
import { FavouritesButton } from '@zooniverse/react-components'
import React from 'react'
import { shallow } from 'enzyme'
import sinon from 'sinon'
import { MetaTools } from './MetaTools'
import Metadata from './components/Metadata'
import CollectionsButton from './components/CollectionsButton'
import { Factory } from 'rosie'

const subjectWithMetadata = Factory.build('subject', { metadata: { foo: 'bar' } })

const favoriteSubject = Factory.build('subject', { favorite: true })

describe('Component > MetaTools', function () {
  it('should render without crashing', function () {
    const wrapper = shallow()
    expect(wrapper).to.be.ok()
  })

  describe('Metadata', function () {
    it('should render a Metadata component', function () {
      const wrapper = shallow()
      expect(wrapper.find(Metadata)).to.have.lengthOf(1)
    })

    it('should pass along the isThereMetadata and subject resource metadata props', function () {
      const wrapper = shallow()
      const metadataComponentProps = wrapper.find(Metadata).props()
github zooniverse / front-end-monorepo / packages / lib-classifier / src / store / FeedbackStore.spec.js View on Github external
id: '51',
          strategy: 'singleAnswerQuestion',
          failureEnabled: true,
          successEnabled: true,
          defaultFailureMessage: '"Actually, that\'s not correct"',
          defaultSuccessMessage: '"Correct"'
        }]
      }
    }
  }
})
const project = ProjectFactory.build({}, {
  activeWorkflowId: workflow.id,
  experimental_tools: ['general feedback']
})
const subject = Factory.build('subject')
subject.shouldDiscuss = undefined

describe('Model > FeedbackStore', function () {
  describe('existance', function () {
    it('should exist', function () {
      expect(FeedbackStore).to.be.ok()
      expect(FeedbackStore).to.be.an('object')
    })
  })

  describe('Actions', function () {
    before(function () {
      sinon.stub(helpers, 'generateRules').callsFake(() => rulesStub)
      strategies.testStrategy = {
        reducer: sinon.stub().callsFake(rule => rule)
      }
github zooniverse / front-end-monorepo / packages / lib-classifier / src / components / Classifier / components / MetaTools / MetaTools.spec.js View on Github external
import { FavouritesButton } from '@zooniverse/react-components'
import React from 'react'
import { shallow } from 'enzyme'
import sinon from 'sinon'
import { MetaTools } from './MetaTools'
import Metadata from './components/Metadata'
import CollectionsButton from './components/CollectionsButton'
import { Factory } from 'rosie'

const subjectWithMetadata = Factory.build('subject', { metadata: { foo: 'bar' } })

const favoriteSubject = Factory.build('subject', { favorite: true })

describe('Component > MetaTools', function () {
  it('should render without crashing', function () {
    const wrapper = shallow()
    expect(wrapper).to.be.ok()
  })

  describe('Metadata', function () {
    it('should render a Metadata component', function () {
      const wrapper = shallow()
      expect(wrapper.find(Metadata)).to.have.lengthOf(1)
    })

    it('should pass along the isThereMetadata and subject resource metadata props', function () {
github typicode / jsonplaceholder / seed.js View on Github external
_(5).times(function () {
      var comment = Factory.build('comment', {postId: post.id})
      db.comments.push(comment)
    })
  })
github zooniverse / front-end-monorepo / packages / lib-classifier / src / components / Classifier / components / SubjectViewer / components / LightCurveViewer / LightCurveViewerContainer.spec.js View on Github external
import { shallow } from 'enzyme'
import React from 'react'
import nock from 'nock'
import sinon from 'sinon'
import * as d3 from 'd3'
import { zip } from 'lodash'

import { LightCurveViewerContainer } from './LightCurveViewerContainer'
import kepler from '../../helpers/mockLightCurves/kepler'
import { Factory } from 'rosie'

let wrapper

const mockData = kepler

const subject = Factory.build('subject', { locations: [
  { 'application/json': 'http://localhost:8080/mockData.json' }
] })

const nextSubject = Factory.build('subject', { locations: [
  { 'text/plain': 'http://localhost:8080/nextSubject.json' }
] })

const nextSubjectJSON = { x: [1, 2], y: [3, 4] }

const imageSubject = Factory.build('subject')

const failSubject = Factory.build('subject', {
  locations: [
    { 'application/json': 'http://localhost:8080/failure.json' }
  ]
})
github typicode / jsonplaceholder / seed.js View on Github external
_(50).times(function() {
      var photo = Factory.build('photo', {albumId: album.id})
      db.photos.push(photo)
    })
  })

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

70 / 100
Full package analysis