Skip to content

Commit

Permalink
Add input literal into the formwrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravShah committed Nov 16, 2018
1 parent 842e7e5 commit 3d1fb3a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
16 changes: 8 additions & 8 deletions __tests__/components/editor/FormWrapper.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
// Copyright 2018 Stanford University see Apache2.txt for license
import React from 'react'
import { shallow } from 'enzyme'
import PropertyTemplate from '../../../src/components/editor/PropertyTemplate'
import InputLiteral from '../../../src/components/editor/InputLiteral'
import FormWrapper from '../../../src/components/editor/FormWrapper'

const rtProps = {
"propertyTemplates": [
[{
"propertyLabel": "Instance of"
"propertyLabel": "Instance of",
"type": "literal"
}],
[{
"propertyLabel": "Instance of"
"propertyLabel": "Instance of",
"type": "target"
}],
[{
"propertyLabel": "Instance of"
"propertyLabel": "Instance of",
"type": "resource"
}]
]
}


describe('<FormWrapper />', () => {
const wrapper = shallow(<FormWrapper {...rtProps} />)
console.log(wrapper.instance())
it('renders the FormWrapper text nodes', () => {
wrapper.find('div.FormWrapper > p').forEach((node) => {
expect(node.containsAnyMatchingElements([
Expand All @@ -31,8 +33,6 @@ describe('<FormWrapper />', () => {
})
})
it('renders FormWrapper nested component', () => {
expect(wrapper
.find('div.FormWrapper > div > PropertyTemplate').length)
.toEqual(1)
expect(wrapper.find('div.FormWrapper > div > InputLiteral').length).toEqual(1)
})
})
7 changes: 6 additions & 1 deletion src/components/editor/FormWrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react'
import PropertyTemplate from './PropertyTemplate'
import InputLiteral from './InputLiteral'

class FormWrapper extends Component{
render () {
Expand All @@ -16,7 +17,11 @@ class FormWrapper extends Component{
<p>BEGIN FormWrapper</p>
<div>
{this.props.propertyTemplates[0].map(function(pt, index){
return <PropertyTemplate key={index} propertyTemplates={[pt]}/>
if(pt.type == 'literal'){
return(
<InputLiteral propertyTemplate = {pt} key = {index} />
)
}
})}
</div>
<p>END FormWrapper</p>
Expand Down
14 changes: 14 additions & 0 deletions src/components/editor/InputLiteral.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, {Component} from 'react';

class InputLiteral extends Component {
render() {
return (
<div>
<label>{this.props.propertyTemplate.propertyLabel}</label>
<input type="text" placeholder={this.props.propertyTemplate.propertyLabel}/>
</div>
)
}
}

export default InputLiteral;

0 comments on commit 3d1fb3a

Please sign in to comment.