Mailspring/spec-nylas/components/form-builder-spec.cjsx
Ben Gotow 92cf2d520c fix(asar): Support ASAR, and running of specs in prod builds
Summary:
fix(task-queue): Repair the findTask function

Add "ship logs" and "open logs" to the developer menu

Patches for Chromium 42

Test Plan: Run tests!

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1547
2015-05-21 14:41:30 -07:00

40 lines
1.6 KiB
CoffeeScript

fs = require 'fs'
path = require 'path'
React = require ('react')
ReactTestUtils = React.addons.TestUtils
{FormItem,
GeneratedForm,
GeneratedFieldset} = require ('../../src/components/generated-form')
fixtureModule = path.resolve(__dirname, '..', '..', 'internal_packages', 'salesforce')
Adapter = require(path.join(fixtureModule, 'lib/salesforce-schema-adapter'))
fpath = path.join(fixtureModule, 'spec/fixtures/opportunity-layouts.json')
rawData = JSON.parse(fs.readFileSync(fpath, 'utf-8'))
testData = Adapter.convertFullEditLayout("opportunity", rawData)
describe "Form Builder", ->
beforeEach ->
for fieldset in testData.fieldsets
for formItem in fieldset.formItems
if formItem.type is "reference"
formItem.type = React.createClass(render: -> <div></div>)
@form = ReactTestUtils.renderIntoDocument(
<GeneratedForm {...testData} onSubmit={->} onChange={->}></GeneratedForm>
)
it "generates a form", ->
forms = ReactTestUtils.scryRenderedComponentsWithType(@form, GeneratedForm)
$forms = ReactTestUtils.scryRenderedDOMComponentsWithTag(@form, "form")
expect(forms.length).toBeGreaterThan 0
expect($forms.length).toBeGreaterThan 0
it "generates a fieldset", ->
fieldsets = ReactTestUtils.scryRenderedComponentsWithType(@form, GeneratedFieldset)
$fieldsets = ReactTestUtils.scryRenderedDOMComponentsWithTag(@form, "fieldset")
expect(fieldsets.length).toBeGreaterThan 0
expect($fieldsets.length).toBeGreaterThan 0
it "generates a form item", ->
items = ReactTestUtils.scryRenderedComponentsWithType(@form, FormItem)
expect(items.length).toBeGreaterThan 0