-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fbae79
commit b2e3d68
Showing
12 changed files
with
178 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { Form } from 'stardust' | ||
import Form from 'src/collections/Form/Form' | ||
import FormField from 'src/collections/Form/FormField' | ||
import FormFields from 'src/collections/Form/FormFields' | ||
|
||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('Form', () => { | ||
common.isConformant(Form) | ||
common.hasUIClassName(Form) | ||
common.hasSubComponents(Form, [FormField, FormFields]) | ||
common.hasSubComponents(Form, [FormField]) | ||
common.rendersChildren(Form) | ||
common.implementsWidthProp(Form, { propKey: 'widths' }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
|
||
import FormField from 'src/collections/Form/FormField' | ||
import FormFieldButton from 'src/collections/Form/FormFieldButton' | ||
import FormFieldCheckbox from 'src/collections/Form/FormFieldCheckbox' | ||
import FormFieldDropdown from 'src/collections/Form/FormFieldDropdown' | ||
import FormFieldGroup from 'src/collections/Form/FormFieldGroup' | ||
import FormFieldInput from 'src/collections/Form/FormFieldInput' | ||
import FormFieldRadio from 'src/collections/Form/FormFieldRadio' | ||
import FormFieldSelect from 'src/collections/Form/FormFieldSelect' | ||
import FormFieldTextArea from 'src/collections/Form/FormFieldTextArea' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormField', () => { | ||
common.isConformant(FormField) | ||
common.implementsWidthProp(FormField, { propKey: 'width', canEqual: false }) | ||
common.propKeyOnlyToClassName(FormField, 'error') | ||
common.propKeyOnlyToClassName(FormField, 'disabled') | ||
common.propKeyOnlyToClassName(FormField, 'inline') | ||
common.propKeyOnlyToClassName(FormField, 'required', { label: '' }) | ||
common.rendersChildren(FormField) | ||
common.hasSubComponents(FormField, [ | ||
FormFieldButton, | ||
FormFieldCheckbox, | ||
FormFieldDropdown, | ||
FormFieldTextArea, | ||
FormFieldGroup, | ||
FormFieldInput, | ||
FormFieldRadio, | ||
FormFieldSelect, | ||
]) | ||
|
||
describe('html controls', () => { | ||
it('adds an HTML element child of the same type', () => { | ||
const controls = ['button', 'input', 'select', 'textarea'] | ||
|
||
controls.forEach((control) => { | ||
shallow(<FormField control={control} />) | ||
.should.have.descendants(control) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('label', () => { | ||
it('does not add a label child by default', () => { | ||
shallow(<FormField />) | ||
.should.not.have.descendants('label') | ||
}) | ||
it('adds a label child', () => { | ||
const wrapper = shallow(<FormField label='First Name' />) | ||
wrapper | ||
.should.have.descendants('label') | ||
|
||
wrapper | ||
.find('label') | ||
.should.contain.text('First Name') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import FormFieldButton from 'src/collections/Form/FormFieldButton' | ||
import Button from 'src/elements/Button/Button' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldButton', () => { | ||
common.isConformant(FormFieldButton) | ||
|
||
it('renders a FormField with a Button control', () => { | ||
shallow(<FormFieldButton />) | ||
.find('FormField') | ||
.should.have.prop('control', Button) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import FormFieldCheckbox from 'src/collections/Form/FormFieldCheckbox' | ||
import Checkbox from 'src/modules/Checkbox/Checkbox' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldCheckbox', () => { | ||
common.isConformant(FormFieldCheckbox) | ||
|
||
it('renders a FormField with a Checkbox control', () => { | ||
shallow(<FormFieldCheckbox />) | ||
.find('FormField') | ||
.should.have.prop('control', Checkbox) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import FormFieldDropdown from 'src/collections/Form/FormFieldDropdown' | ||
import Dropdown from 'src/modules/Dropdown/Dropdown' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldDropdown', () => { | ||
common.isConformant(FormFieldDropdown) | ||
|
||
it('renders a FormField with a Dropdown control', () => { | ||
shallow(<FormFieldDropdown />) | ||
.find('FormField') | ||
.should.have.prop('control', Dropdown) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import FormFieldGroup from 'src/collections/Form/FormFieldGroup' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldGroup', () => { | ||
common.isConformant(FormFieldGroup) | ||
common.rendersChildren(FormFieldGroup) | ||
common.propKeyOnlyToClassName(FormFieldGroup, 'grouped') | ||
common.propKeyOnlyToClassName(FormFieldGroup, 'inline') | ||
common.implementsWidthProp(FormFieldGroup, { propKey: 'widths', canEqual: true }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import FormFieldInput from 'src/collections/Form/FormFieldInput' | ||
import Input from 'src/elements/Input/Input' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldInput', () => { | ||
common.isConformant(FormFieldInput) | ||
|
||
it('renders a FormField with a Input control', () => { | ||
shallow(<FormFieldInput />) | ||
.find('FormField') | ||
.should.have.prop('control', Input) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import FormFieldRadio from 'src/collections/Form/FormFieldRadio' | ||
import Radio from 'src/addons/Radio/Radio' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldRadio', () => { | ||
common.isConformant(FormFieldRadio) | ||
|
||
it('renders a FormField with a Radio control', () => { | ||
shallow(<FormFieldRadio />) | ||
.find('FormField') | ||
.should.have.prop('control', Radio) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import FormFieldSelect from 'src/collections/Form/FormFieldSelect' | ||
import Select from 'src/addons/Select/Select' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldSelect', () => { | ||
common.isConformant(FormFieldSelect) | ||
|
||
it('renders a FormField with a Select control', () => { | ||
shallow(<FormFieldSelect />) | ||
.find('FormField') | ||
.should.have.prop('control', Select) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react' | ||
|
||
import FormFieldTextArea from 'src/collections/Form/FormFieldTextArea' | ||
import TextArea from 'src/addons/TextArea/TextArea' | ||
import * as common from 'test/specs/commonTests' | ||
|
||
describe('FormFieldTextArea', () => { | ||
common.isConformant(FormFieldTextArea) | ||
|
||
it('renders a FormField with a TextArea control', () => { | ||
shallow(<FormFieldTextArea />) | ||
.find('FormField') | ||
.should.have.prop('control', TextArea) | ||
}) | ||
}) |