Skip to content

Commit

Permalink
Merge branch 'master' into token-db-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Nov 29, 2016
2 parents 786a86d + 0aa6a3c commit ff2bcf2
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 563 deletions.
28 changes: 0 additions & 28 deletions tests/view/components/detailViewTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,6 @@ describe('Detail view ', () => {
return enzymeWrapper;
}

it('state overwrites form Object when the latter has empty array', () => {
const formObj = { name: DUMMY_STRING, tags: [] };
const invalidFieldObj = { tags: [' I am invalid'] };
const updatedObj = Object.assign(formObj, invalidFieldObj);
expect(updatedObj.tags).to.deep.equal(invalidFieldObj.tags);
});

it('state overwrites form Object when the latter has empty string', () => {
const formObj = { name: DUMMY_STRING, helpEmail: '' };
const invalidFieldObj = { helpEmail: DUMMY_STRING };
const updatedObj = Object.assign(formObj, invalidFieldObj);
expect(updatedObj.helpEmail).to.deep.equal(invalidFieldObj.helpEmail);
});

it('state overwrites form Object when the latter is non-empty string', () => {
const formObj = { name: DUMMY_STRING, helpEmail: 'valid@email.com' };
const invalidFieldObj = { helpEmail: DUMMY_STRING };
const updatedObj = Object.assign(formObj, invalidFieldObj);
expect(updatedObj.helpEmail).to.deep.equal(invalidFieldObj.helpEmail);
});

it('state overwrites form Object when the latter has values', () => {
const formObj = { name: DUMMY_STRING, tags: ['valid_tag'] };
const invalidFieldObj = { tags: [' I am invalid'] };
const updatedObj = Object.assign(formObj, invalidFieldObj);
expect(updatedObj.tags).to.deep.equal(invalidFieldObj.tags);
});

it('should render button row with three buttons as expected', () => {
const enzymeWrapper = setup();
// button row container
Expand Down
99 changes: 56 additions & 43 deletions tests/view/components/formTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,74 @@ import { expect } from 'chai';
import Form from '../../../view/admin/components/common/Forms.js';

describe('Forms', () => {
const FIELD_NAME = 'hello_world';

// TODO: troubleshoot why Inconstiant Violation: Objects are not valid as a React child
var FIELD_NAME = 'hello_world';

// TODO: troubleshoot why Invariant Violation: Objects are not valid as a React child
it.skip('calling Form with customOutput, renders the expected output', () => {
const metaData = [{
var metaData = [{
propertyName: 'parentAbsolutePath',
displayName: 'Parent Absolute Path',
customOutput: function(data) {
return <div className='parentAbsolutePath'>{data}</div>;
},
},
];
const data = {
var data = {
parentAbsolutePath: 'sccdsd',
};

const form = TestUtils.renderIntoDocument(
var form = TestUtils.renderIntoDocument(
<Form propertyMetaData={metaData} data={data}/>
);
const field = TestUtils
var field = TestUtils
.findRenderedDOMComponentWithClass(form, 'parentAbsolutePath');
expect(field.textContent).to.equal(data.parentAbsolutePath);
});

it('calling Form with no propertyMetadata, returns empty form');

it('on read, parentAbsolutePath should be populated, from data', () => {
const metaData = [{
var metaData = [{
propertyName: 'parentAbsolutePath',
displayName: 'Parent Absolute Path',
},
];
const data = {
var data = {
parentAbsolutePath: 'sccdsd',
};
const form = TestUtils.renderIntoDocument(
var form = TestUtils.renderIntoDocument(
<Form propertyMetaData={metaData} data={data}/>
);
const field = TestUtils.findRenderedDOMComponentWithTag(form, 'p');
var field = TestUtils.findRenderedDOMComponentWithTag(form, 'p');
expect(field.textContent).to.equal(data.parentAbsolutePath);
});

it('getFormData returns updated value, after input value change');

it('getFormData returns expected JSON representation given ' +
'form with radio buttons');

it('getFormData returns expected JSON representation given ' +
'form with inputs whose names include _');

it('getFormData returns expected JSON representation given ' +
'form with percent values in input text');

it('form field renders with default value, as provided', () => {
const propertyMetaData = [
var propertyMetaData = [
{
propertyName: 'name',
displayName: 'Name',
},
];
const data = {
var data = {
name: FIELD_NAME,
};
const form = TestUtils.renderIntoDocument(
var form = TestUtils.renderIntoDocument(
<Form propertyMetaData={propertyMetaData} edit={true} data={data}/>
);
const inputTag = TestUtils.findRenderedDOMComponentWithTag(form, 'input');
var inputTag = TestUtils.findRenderedDOMComponentWithTag(form, 'input');
expect(inputTag.value).to.equal(FIELD_NAME);
});

Expand All @@ -83,7 +95,7 @@ describe('Forms', () => {
it('Editable fields, after a readOnly field, is editable.',
() => {

const propertyMetaData = [
var propertyMetaData = [
{
propertyName: 'name',
displayName: 'Name',
Expand All @@ -93,97 +105,98 @@ describe('Forms', () => {
readOnly: true,
},
];
const data = {
var data = {
name: 'hello world',
createdById: '14356iyu',
};
const form = TestUtils.renderIntoDocument(
var form = TestUtils.renderIntoDocument(
<Form propertyMetaData={propertyMetaData} edit={true} data={data}/>
);
const labelTags = TestUtils.scryRenderedDOMComponentsWithTag(form, 'label');
const pTag = TestUtils.findRenderedDOMComponentWithTag(form, 'p');
const inputTag = TestUtils.findRenderedDOMComponentWithTag(form, 'input');
var labelTags = TestUtils.scryRenderedDOMComponentsWithTag(form, 'label');
var pTag = TestUtils.findRenderedDOMComponentWithTag(form, 'p');
var inputTag = TestUtils.findRenderedDOMComponentWithTag(form, 'input');
expect(labelTags.length).to.equal(2);
expect(inputTag).to.not.be.null;
expect(pTag).to.not.be.null;
});

it('Form is editable when edit is true', () => {
const propertyMetaData = [{
var propertyMetaData = [{
propertyName: 'name',
displayName: 'Name',
},
];
const formWithOneField = TestUtils.renderIntoDocument(
var formWithOneField = TestUtils.renderIntoDocument(
<Form propertyMetaData={propertyMetaData} edit={true}/>
);
const labelTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'label');
const inputTags = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'input');
const pTags = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'p');
var labelTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'label');
var inputTags = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'input');
var pTags = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'p');
expect(formWithOneField.props.edit).to.equal(true);
expect(inputTags.length).to.equal(1);
expect(pTags.length).to.equal(0);
});

it('Non-existent data, renders into N/A when form is non-editable', () => {
const propertyMetaData = [{
var propertyMetaData = [{
propertyName: 'name',
displayName: 'Name',
},
];
const formWithOneField = TestUtils.renderIntoDocument(
var formWithOneField = TestUtils.renderIntoDocument(
<Form propertyMetaData={propertyMetaData}/>
);
const labelTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'label');
const pTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'p');
var inputTag;
var labelTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'label');
var pTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'p');
expect(labelTag.textContent).to.equal('Name');
expect(pTag.textContent).to.equal('N/A');
});

it('By default, form is non-editable. One field returns a label, with paragraph', () => {
const propertyMetaData = [{
var propertyMetaData = [{
propertyName: 'name',
displayName: 'Name',
},
];
const data = {
var data = {
name: 'hello world',
};
const formWithOneField = TestUtils.renderIntoDocument(
var formWithOneField = TestUtils.renderIntoDocument(
<Form propertyMetaData={propertyMetaData} data={data}/>
);
const labelTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'label');
const pTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'p');
var labelTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'label');
var pTag = TestUtils.findRenderedDOMComponentWithTag(formWithOneField, 'p');
expect(labelTag.textContent).to.equal('Name');
expect(pTag.textContent).to.equal('hello world');
});

it('Empty metadata passed in, results in empty form', () => {
const propertyMetaData = [];
const emptyForm = TestUtils.renderIntoDocument(
var propertyMetaData = [];
var emptyForm = TestUtils.renderIntoDocument(
<Form propertyMetaData={propertyMetaData}/>
);
const pTags = TestUtils.scryRenderedDOMComponentsWithTag(emptyForm, 'p');
var pTags = TestUtils.scryRenderedDOMComponentsWithTag(emptyForm, 'p');
expect(pTags).to.be.empty;
});

it('Input fields should match propertyMetadata objects', () => {
// Limiting fields by propertyMetaData works
const propertyMetaData = [{
//Limiting fields by propertyMetaData works
var propertyMetaData = [{
propertyName: 'name',
displayName: 'Name',
},
];
const data = {
var data = {
name: 'hello world',
code: 'hello world',
achoo: 'hello world',
};
const formWithOneField = TestUtils.renderIntoDocument(
var formWithOneField = TestUtils.renderIntoDocument(
<Form propertyMetaData={propertyMetaData} data={data}/>
);
const labelTag = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'label');
const pTag = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'p');
var labelTag = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'label');
var pTag = TestUtils.scryRenderedDOMComponentsWithTag(formWithOneField, 'p');
expect(labelTag.length).to.equal(pTag.length);
expect(propertyMetaData.length).to.equal(pTag.length);
});
Expand Down
106 changes: 0 additions & 106 deletions tests/view/components/listTest.js

This file was deleted.

0 comments on commit ff2bcf2

Please sign in to comment.