Skip to content

Commit

Permalink
tests(mixed): remove usage of meta.props (Semantic-Org#1239)
Browse files Browse the repository at this point in the history
* tests(mixed): remove usage of `meta.props`

* tests(mixed): fix lint issues

* tests(mixed): some fixes

* fix(Grid): fix test

* fix(Button): update ButtonGroup's test

* fix(tests): add default props
  • Loading branch information
layershifter authored and harel committed Feb 18, 2017
1 parent 6079eb9 commit 4ef3bbd
Show file tree
Hide file tree
Showing 27 changed files with 142 additions and 93 deletions.
4 changes: 2 additions & 2 deletions test/specs/collections/Form/Form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe('Form', () => {
])
common.rendersChildren(Form)

common.implementsWidthProp(Form, _.without(SUI.SIZES, 'medium'), { propKey: 'widths' })

common.propKeyOnlyToClassName(Form, 'error')
common.propKeyOnlyToClassName(Form, 'inverted')
common.propKeyOnlyToClassName(Form, 'loading')
Expand All @@ -41,8 +43,6 @@ describe('Form', () => {

common.propValueOnlyToClassName(Form, 'size', _.without(SUI.SIZES, 'medium'))

common.implementsWidthProp(Form, { propKey: 'widths' })

describe('serializer', () => {
it('defaults to a function', () => {
Form.defaultProps
Expand Down
17 changes: 9 additions & 8 deletions test/specs/collections/Form/FormField-test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import faker from 'faker'
import React from 'react'

import Checkbox from 'src/modules/Checkbox/Checkbox'
import FormField from 'src/collections/Form/FormField'
import Radio from 'src/addons/Radio/Radio'
import FormField from 'src/collections/Form/FormField'
import { SUI } from 'src/lib'
import Checkbox from 'src/modules/Checkbox/Checkbox'
import * as common from 'test/specs/commonTests'

describe('FormField', () => {
common.isConformant(FormField)
common.rendersChildren(FormField)

common.implementsHTMLLabelProp(FormField)
common.implementsWidthProp(FormField, SUI.WIDTHS, {
canEqual: false,
propKey: 'width',
})

common.propKeyOnlyToClassName(FormField, 'disabled')
common.propKeyOnlyToClassName(FormField, 'error')
common.propKeyOnlyToClassName(FormField, 'inline')
common.propKeyOnlyToClassName(FormField, 'required', {
requiredProps: { label: '' },
})

common.implementsHTMLLabelProp(FormField)
common.implementsWidthProp(FormField, {
propKey: 'width',
canEqual: false,
})

describe('control', () => {
it('adds an HTML element child of the same type', () => {
const controls = ['button', 'input', 'select', 'textarea']
Expand Down
8 changes: 7 additions & 1 deletion test/specs/collections/Form/FormFieldGroup-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import FormGroup from 'src/collections/Form/FormGroup'
import { SUI } from 'src/lib'
import * as common from 'test/specs/commonTests'

describe('FormGroup', () => {
common.isConformant(FormGroup)
common.rendersChildren(FormGroup)

common.implementsWidthProp(FormGroup, SUI.WIDTHS, {
canEqual: true,
propKey: 'widths',
})

common.propKeyOnlyToClassName(FormGroup, 'grouped')
common.propKeyOnlyToClassName(FormGroup, 'inline')
common.implementsWidthProp(FormGroup, { propKey: 'widths', canEqual: true })
})
8 changes: 5 additions & 3 deletions test/specs/collections/Grid/Grid-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as common from 'test/specs/commonTests'
import Grid from 'src/collections/Grid/Grid'
import GridColumn from 'src/collections/Grid/GridColumn'
import GridRow from 'src/collections/Grid/GridRow'
import { SUI } from 'src/lib'

describe('Grid', () => {
common.isConformant(Grid)
Expand All @@ -12,13 +13,14 @@ describe('Grid', () => {

common.implementsTextAlignProp(Grid)
common.implementsVerticalAlignProp(Grid)
common.implementsWidthProp(Grid, {
canEqual: true,
common.implementsWidthProp(Grid, SUI.WIDTHS, {
propKey: 'columns',
widthClass: 'column',
})

common.propKeyAndValueToClassName(Grid, 'reversed')
common.propKeyAndValueToClassName(Grid, 'reversed', [
'computer', 'computer vertically', 'mobile', 'mobile vertically', 'tablet', 'tablet vertically',
])

common.propKeyOnlyToClassName(Grid, 'centered')
common.propKeyOnlyToClassName(Grid, 'container')
Expand Down
42 changes: 28 additions & 14 deletions test/specs/collections/Grid/GridColumn-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,41 @@ describe('GridColumn', () => {
common.implementsTextAlignProp(GridColumn)
common.implementsVerticalAlignProp(GridColumn)

common.implementsWidthProp(GridColumn, {
propKey: 'computer', widthClass: 'wide computer', canEqual: false,
common.implementsWidthProp(GridColumn, SUI.WIDTHS, {
canEqual: false,
propKey: 'computer',
widthClass: 'wide computer',
})
common.implementsWidthProp(GridColumn, {
propKey: 'largeScreen', widthClass: 'wide large screen', canEqual: false,
common.implementsWidthProp(GridColumn, SUI.WIDTHS, {
canEqual: false,
propKey: 'largeScreen',
widthClass: 'wide large screen',
})
common.implementsWidthProp(GridColumn, {
propKey: 'mobile', widthClass: 'wide mobile', canEqual: false,
common.implementsWidthProp(GridColumn, SUI.WIDTHS, {
canEqual: false,
propKey: 'mobile',
widthClass: 'wide mobile',
})
common.implementsWidthProp(GridColumn, {
propKey: 'tablet', widthClass: 'wide tablet', canEqual: false,
common.implementsWidthProp(GridColumn, SUI.WIDTHS, {
canEqual: false,
propKey: 'tablet',
widthClass: 'wide tablet',
})
common.implementsWidthProp(GridColumn, {
propKey: 'widescreen', widthClass: 'wide widescreen', canEqual: false,
common.implementsWidthProp(GridColumn, SUI.WIDTHS, {
canEqual: false,
propKey: 'widescreen',
widthClass: 'wide widescreen',
})
common.implementsWidthProp(GridColumn, {
propKey: 'width', widthClass: 'wide', canEqual: false,
common.implementsWidthProp(GridColumn, SUI.WIDTHS, {
canEqual: false,
propKey: 'width',
widthClass: 'wide',
})

common.propKeyAndValueToClassName(GridColumn, 'floated')
common.propKeyAndValueToClassName(GridColumn, 'only')
common.propKeyAndValueToClassName(GridColumn, 'floated', SUI.FLOATS)
common.propKeyAndValueToClassName(GridColumn, 'only', [
'computer', 'large screen', 'mobile', 'tablet mobile', 'tablet', 'widescreen',
])

common.propKeyOnlyToClassName(GridColumn, 'stretched')

Expand Down
13 changes: 10 additions & 3 deletions test/specs/collections/Grid/GridRow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ describe('GridRow', () => {

common.implementsTextAlignProp(GridRow)
common.implementsVerticalAlignProp(GridRow)
common.implementsWidthProp(GridRow, { propKey: 'columns', widthClass: 'column', canEqual: true })
common.implementsWidthProp(GridRow, SUI.WIDTHS, {
propKey: 'columns',
widthClass: 'column',
})

common.propKeyAndValueToClassName(GridRow, 'only')
common.propKeyAndValueToClassName(GridRow, 'reversed')
common.propKeyAndValueToClassName(GridRow, 'only', [
'computer', 'large screen', 'mobile', 'tablet mobile', 'tablet', 'widescreen',
])
common.propKeyAndValueToClassName(GridRow, 'reversed', [
['computer', 'computer vertically', 'mobile', 'mobile vertically', 'tablet', 'tablet vertically'],
])

common.propKeyOnlyToClassName(GridRow, 'centered')
common.propKeyOnlyToClassName(GridRow, 'divided')
Expand Down
7 changes: 5 additions & 2 deletions test/specs/collections/Menu/Menu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ describe('Menu', () => {
common.hasUIClassName(Menu)
common.rendersChildren(Menu)

common.implementsWidthProp(Menu, { propKey: 'widths', canEqual: false })
common.implementsWidthProp(Menu, SUI.WIDTHS, {
canEqual: false,
propKey: 'widths',
})

common.propKeyAndValueToClassName(Menu, 'fixed')
common.propKeyAndValueToClassName(Menu, 'fixed', ['left', 'right', 'bottom', 'top'])

common.propKeyOnlyToClassName(Menu, 'borderless')
common.propKeyOnlyToClassName(Menu, 'compact')
Expand Down
2 changes: 1 addition & 1 deletion test/specs/collections/Table/Table-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Table', () => {
common.hasUIClassName(Table)
common.rendersChildren(Table)

common.implementsWidthProp(Table, {
common.implementsWidthProp(Table, SUI.WIDTHS, {
canEqual: false,
propKey: 'columns',
widthClass: 'column',
Expand Down
7 changes: 6 additions & 1 deletion test/specs/collections/Table/TableCell-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'

import * as common from 'test/specs/commonTests'
import TableCell from 'src/collections/Table/TableCell'
import { SUI } from 'src/lib'

describe('TableCell', () => {
common.isConformant(TableCell)
Expand All @@ -10,7 +11,11 @@ describe('TableCell', () => {
common.implementsCreateMethod(TableCell)
common.implementsTextAlignProp(TableCell, ['left', 'center', 'right'])
common.implementsVerticalAlignProp(TableCell)
common.implementsWidthProp(TableCell, { propKey: 'width', widthClass: 'wide', canEqual: false })
common.implementsWidthProp(TableCell, SUI.WIDTHS, {
canEqual: false,
propKey: 'width',
widthClass: 'wide',
})

common.propKeyOnlyToClassName(TableCell, 'active')
common.propKeyOnlyToClassName(TableCell, 'collapsing')
Expand Down
2 changes: 1 addition & 1 deletion test/specs/collections/Table/TableHeaderCell-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import TableHeaderCell from 'src/collections/Table/TableHeaderCell'

describe('TableHeaderCell', () => {
common.isConformant(TableHeaderCell)
common.propKeyAndValueToClassName(TableHeaderCell, 'sorted')
common.propKeyAndValueToClassName(TableHeaderCell, 'sorted', ['ascending', 'descending'])

it('renders as a th by default', () => {
shallow(<TableHeaderCell />)
Expand Down
Loading

0 comments on commit 4ef3bbd

Please sign in to comment.