Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(tests): mixed lint updates #1939

Merged
merged 2 commits into from
Aug 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/specs/addons/Portal/Portal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('Portal', () => {
})

it('maintains ref to DOM node with React component', () => {
const Component = (props) => <p />
const Component = () => <p />

wrapperMount(<Portal open><Component /></Portal>)
wrapper.instance().portalNode.tagName.should.equal('P')
Expand Down Expand Up @@ -262,7 +262,7 @@ describe('Portal', () => {
wrapperMount(
<Portal trigger={<button />} defaultOpen closeOnTriggerClick>
<p />
</Portal>
</Portal>,
)

wrapper.find('button').simulate('click')
Expand Down Expand Up @@ -308,7 +308,7 @@ describe('Portal', () => {
wrapperMount(
<Portal trigger={<button />} defaultOpen closeOnTriggerMouseLeave mouseLeaveDelay={0}>
<p />
</Portal>
</Portal>,
)

document.body.lastElementChild.should.equal(wrapper.instance().rootNode)
Expand Down Expand Up @@ -337,7 +337,7 @@ describe('Portal', () => {
wrapperMount(
<Portal trigger={<button />} defaultOpen closeOnPortalMouseLeave mouseLeaveDelay={0}>
<p />
</Portal>
</Portal>,
)

document.body.lastElementChild.should.equal(wrapper.instance().rootNode)
Expand All @@ -354,7 +354,7 @@ describe('Portal', () => {
it('closes the portal on trigger mouseleave even when portal receives mouseenter within limit', (done) => {
const delay = 10
wrapperMount(
<Portal trigger={<button />} defaultOpen closeOnTriggerMouseLeave mouseLeaveDelay={delay}><p /></Portal>
<Portal trigger={<button />} defaultOpen closeOnTriggerMouseLeave mouseLeaveDelay={delay}><p /></Portal>,
)

wrapper.find('button').simulate('mouseleave')
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('Portal', () => {
mouseLeaveDelay={delay}
>
<p />
</Portal>
</Portal>,
)

wrapper.find('button').simulate('mouseleave')
Expand Down
2 changes: 1 addition & 1 deletion test/specs/addons/TextArea/TextArea-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('TextArea', () => {
autoHeight
style={style}
value={'line1\nline2\nline3\nline4'}
/>
/>,
)
assertHeight('40px') // 4 lines
})
Expand Down
2 changes: 1 addition & 1 deletion test/specs/behaviors/Visibility/Visibility-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Visibility', () => {
})

describe('calculations', () => {
expectations.forEach(expectation => {
expectations.forEach((expectation) => {
it(`calculates ${expectation.name}`, () => {
let calculations
const onUpdate = (e, props) => (calculations = props.calculations)
Expand Down
2 changes: 1 addition & 1 deletion test/specs/collections/Form/FormField-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('FormField', () => {
it('adds an HTML element child of the same type', () => {
const controls = ['button', 'input', 'select', 'textarea']

controls.forEach(control => {
controls.forEach((control) => {
shallow(<FormField control={control} />)
.should.have.descendants(control)
})
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 @@ -48,7 +48,7 @@ describe('Table', () => {

common.propValueOnlyToClassName(Table, 'color', SUI.COLORS)
common.propValueOnlyToClassName(Table, 'size',
_.without(SUI.SIZES, 'mini', 'tiny', 'medium', 'big', 'huge', 'massive')
_.without(SUI.SIZES, 'mini', 'tiny', 'medium', 'big', 'huge', 'massive'),
)

it('renders as a table by default', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/commonTests/classNameHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { consoleUtil } from 'test/utils'
export const classNamePropValueBeforePropName = (Component, propKey, propValues, options = {}) => {
const { className = propKey, requiredProps = {} } = options

propValues.forEach(propVal => {
propValues.forEach((propVal) => {
it(`adds "${propVal} ${className}" to className`, () => {
shallow(createElement(Component, { ...requiredProps, [propKey]: propVal }))
.should.have.className(`${propVal} ${className}`)
Expand Down
8 changes: 4 additions & 4 deletions test/specs/commonTests/commonHelpers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export default (testName, Component) => {
const throwError = msg => {
const throwError = (msg) => {
throw new Error(`${testName}: ${msg} \n Component: ${Component && Component.name}`)
}

const assertRequired = (required, description) => {
return required || throwError(`Required ${description}, got: ${required} (${typeof required})`)
}
const assertRequired = (required, description) => (
required || throwError(`Required ${description}, got: ${required} (${typeof required})`)
)

return {
assertRequired,
Expand Down
4 changes: 2 additions & 2 deletions test/specs/commonTests/componentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import helpers from './commonHelpers'
const componentCtx = require.context(
'../../../src/',
true,
/(addons|behaviors|collections|elements|modules|views).\w+.(?!index)\w+.js/
/(addons|behaviors|collections|elements|modules|views).\w+.(?!index)\w+.js/,
)

const componentInfo = componentCtx.keys().map(key => {
const componentInfo = componentCtx.keys().map((key) => {
const Component = componentCtx(key).default
const componentType = typeof Component
const { throwError } = helpers('componentInfo', Component)
Expand Down
2 changes: 1 addition & 1 deletion test/specs/commonTests/hasSubComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import _ from 'lodash'
export default (Component, subComponents) => {
const staticValues = _.values(Component)

_.each(subComponents, subComponent => {
_.each(subComponents, (subComponent) => {
it(`has sub component ${subComponent._meta.name}`, () => {
staticValues.should.contain(subComponent)
})
Expand Down
4 changes: 2 additions & 2 deletions test/specs/commonTests/hasValidTypings.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import _ from 'lodash'
import path from 'path'

import { customPropTypes } from 'src/lib'
import componentInfo from './componentInfo'
import {
getNodes,
getInterfaces,
hasAnySignature,
requireTs,
} from './tsHelpers'
import { customPropTypes } from 'src/lib'

const isShorthand = propType => _.includes([
customPropTypes.collectionShorthand,
Expand Down Expand Up @@ -38,7 +38,7 @@ export default (Component, extractedInfo, options = {}) => {
} = extractedInfo || _.find(componentInfo, i => i.constructorName === Component.prototype.constructor.name)
const { ignoredTypingsProps = [], requiredProps } = options

const tsFile = filenameWithoutExt + '.d.ts'
const tsFile = `${filenameWithoutExt}.d.ts`
const tsContent = requireTs(path.join(path.dirname(filePath), tsFile))

describe('typings', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/specs/commonTests/implementsClassNameProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const propKeyOrValueAndKeyToClassName = (Component, propKey, propValues,
wrapper.should.not.have.className('true')
wrapper.should.not.have.className('false')

_.each(propValues, propVal => {
_.each(propValues, (propVal) => {
wrapper.should.not.have.className(propVal)
})
})
Expand Down Expand Up @@ -128,7 +128,7 @@ export const propValueOnlyToClassName = (Component, propKey, propValues, options
noDefaultClassNameFromProp(Component, propKey, propValues, options)

it('adds prop value to className', () => {
propValues.forEach(propValue => {
propValues.forEach((propValue) => {
shallow(createElement(Component, { ...requiredProps, [propKey]: propValue }))
.should.have.className(propValue)
})
Expand All @@ -137,7 +137,7 @@ export const propValueOnlyToClassName = (Component, propKey, propValues, options
it('does not add prop name to className', () => {
consoleUtil.disableOnce()

propValues.forEach(propValue => {
propValues.forEach((propValue) => {
shallow(createElement(Component, { ...requiredProps, [propKey]: propValue }))
.should.not.have.className(propKey)
})
Expand Down
20 changes: 10 additions & 10 deletions test/specs/commonTests/implementsCommonProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const implementsLabelProp = (Component, options = {}) => {
* Assert that a Component correctly implements the "only" prop.
* @param {React.Component|Function} Component The component to test.
*/
export const implementsOnlyProp = Component => {
export const implementsOnlyProp = (Component) => {
const { assertRequired } = helpers('propKeyAndValueToClassName', Component)
const propValues = SUI.VISIBILITY

Expand All @@ -170,7 +170,7 @@ export const implementsOnlyProp = Component => {
noDefaultClassNameFromProp(Component, 'only', propValues)
noClassNameFromBoolProps(Component, 'only', propValues)

propValues.forEach(propVal => {
propValues.forEach((propVal) => {
it(`adds "${propVal} only" to className`, () => {
shallow(createElement(Component, { only: propVal })).should.have.className(`${propVal} only`)
})
Expand Down Expand Up @@ -202,18 +202,18 @@ export const implementsTextAlignProp = (Component, alignments = SUI.TEXT_ALIGNME
noClassNameFromBoolProps(Component, 'textAlign', alignments, options)
noDefaultClassNameFromProp(Component, 'textAlign', alignments, options)

alignments.forEach(propVal => {
alignments.forEach((propVal) => {
if (propVal === 'justified') {
it('adds "justified" without "aligned" to className', () => {
shallow(<Component { ...requiredProps } textAlign='justified' />)
shallow(<Component {...requiredProps} textAlign='justified' />)
.should.have.className('justified')

shallow(<Component { ...requiredProps } textAlign='justified' />)
shallow(<Component {...requiredProps} textAlign='justified' />)
.should.not.have.className('aligned')
})
} else {
it(`adds "${propVal} aligned" to className`, () => {
shallow(<Component { ...requiredProps } textAlign={propVal} />)
shallow(<Component {...requiredProps} textAlign={propVal} />)
.should.have.className(`${propVal} ${'aligned'}`)
})
}
Expand All @@ -238,9 +238,9 @@ export const implementsVerticalAlignProp = (Component, alignments = SUI.VERTICAL
noClassNameFromBoolProps(Component, 'verticalAlign', alignments, options)
noDefaultClassNameFromProp(Component, 'verticalAlign', alignments, options)

alignments.forEach(propVal => {
alignments.forEach((propVal) => {
it(`adds "${propVal} aligned" to className`, () => {
shallow(<Component { ...requiredProps } verticalAlign={propVal} />)
shallow(<Component {...requiredProps} verticalAlign={propVal} />)
.should.have.className(`${propVal} ${'aligned'}`)
})
})
Expand Down Expand Up @@ -275,7 +275,7 @@ export const implementsWidthProp = (Component, widths = SUI.WIDTHS, options = {}
noDefaultClassNameFromProp(Component, propKey, propValues, options)

it('adds numberToWord value to className', () => {
widths.forEach(width => {
widths.forEach((width) => {
const expectClass = widthClass ? `${numberToWord(width)} ${widthClass}` : numberToWord(width)

shallow(createElement(Component, { ...requiredProps, [propKey]: width }))
Expand All @@ -296,7 +296,7 @@ export const implementsWidthProp = (Component, widths = SUI.WIDTHS, options = {}
* Assert that a Components with a label correctly implements the "id" and "htmlFor" props.
* @param {React.Component|Function} Component The component to test.
*/
export const labelImplementsHtmlForProp = Component => {
export const labelImplementsHtmlForProp = (Component) => {
const { assertRequired } = helpers('labelImplementsHtmlForProp', Component)

describe('htmlFor (common)', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/specs/commonTests/implementsShorthandProp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { consoleUtil } from 'test/utils'
import { noDefaultClassNameFromProp } from './classNameHelpers'
import helpers from './commonHelpers'

const shorthandComponentName = ShorthandComponent => {
const shorthandComponentName = (ShorthandComponent) => {
if (typeof ShorthandComponent === 'string') return ShorthandComponent
return _.get(ShorthandComponent, '_meta.name') || ShorthandComponent.displayName || ShorthandComponent.name
}
Expand Down Expand Up @@ -56,7 +56,7 @@ export default (Component, options = {}) => {
shallow(element).should[assertMethod](shorthandElement)
}

if (alwaysPresent || Component.defaultProps && Component.defaultProps[propKey]) {
if (alwaysPresent || (Component.defaultProps && Component.defaultProps[propKey])) {
it(`has default ${name} when not defined`, () => {
shallow(<Component {...requiredProps} />)
.should.have.descendants(name)
Expand Down
28 changes: 14 additions & 14 deletions test/specs/commonTests/isConformant.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import ReactDOMServer from 'react-dom/server'
import * as semanticUIReact from 'semantic-ui-react'

import { META } from 'src/lib'
import { consoleUtil, sandbox, syntheticEvent } from 'test/utils'
import helpers from './commonHelpers'
import componentInfo from './componentInfo'
import hasValidTypings from './hasValidTypings'
import { consoleUtil, sandbox, syntheticEvent } from 'test/utils'

/**
* Assert Component conforms to guidelines that are applicable to all components.
Expand Down Expand Up @@ -76,13 +76,13 @@ export default (Component, options = {}) => {
expect(isTopLevelAPIProp).to.equal(
false,
`"${constructorName}" is private (starts with "_").` +
' It cannot be exposed on the top level API'
' It cannot be exposed on the top level API',
)

expect(isSubComponent).to.equal(
false,
`"${constructorName}" is private (starts with "_").` +
' It cannot be a static prop of another component (sub-component)'
' It cannot be a static prop of another component (sub-component)',
)
})
} else {
Expand All @@ -100,7 +100,7 @@ export default (Component, options = {}) => {
expect(isSubComponent).to.equal(
true,
`\`${constructorName}\` is a child component (has a _meta.parent).` +
` It must be a static prop of its parent \`${_meta.parent}\``
` It must be a static prop of its parent \`${_meta.parent}\``,
)
})
}
Expand Down Expand Up @@ -158,7 +158,7 @@ export default (Component, options = {}) => {
})

it('renders as a ReactClass or passes "as" to the next component', () => {
class MyComponent extends React.Component {
class MyComponent extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
return <div data-my-react-class />
}
Expand Down Expand Up @@ -199,7 +199,7 @@ export default (Component, options = {}) => {

Component.handledProps.should.to.deep.equal(expectedProps,
'It seems that not all props were defined in Component.handledProps, you need to check that they are equal ' +
'to the union of Component.autoControlledProps and keys of Component.defaultProps and Component.propTypes'
'to the union of Component.autoControlledProps and keys of Component.defaultProps and Component.propTypes',
)
})
})
Expand All @@ -217,7 +217,7 @@ export default (Component, options = {}) => {
// This test catches the case where a developer forgot to call the event prop
// after handling it internally. It also catch cases where the synthetic event was not passed back.
_.each(syntheticEvent.types, ({ eventShape, listeners }) => {
_.each(listeners, listenerName => {
_.each(listeners, (listenerName) => {
// onKeyDown => keyDown
const eventName = _.camelCase(listenerName.replace('on', ''))

Expand Down Expand Up @@ -251,7 +251,7 @@ export default (Component, options = {}) => {
handlerSpy.calledOnce.should.equal(true,
`<${constructorName} ${listenerName}={${handlerName}} />\n` +
`${leftPad} ^ was not called once on "${eventName}".` +
'You may need to hoist your event handlers up to the root element.\n'
'You may need to hoist your event handlers up to the root element.\n',
)

let expectedArgs = [eventShape]
Expand All @@ -263,12 +263,12 @@ export default (Component, options = {}) => {
}

// Components should return the event first, then any data
handlerSpy.calledWithMatch(...expectedArgs).should.equal(true,
`<${constructorName} ${listenerName}={${handlerName}} />\n` +
`${leftPad} ^ ${errorMessage}\n` +
'It was called with args:\n' +
JSON.stringify(handlerSpy.args, null, 2)
)
handlerSpy.calledWithMatch(...expectedArgs).should.equal(true, [
`<${constructorName} ${listenerName}={${handlerName}} />\n`,
`${leftPad} ^ ${errorMessage}`,
'It was called with args:',
JSON.stringify(handlerSpy.args, null, 2),
].join('\n'))
})
})
})
Expand Down
Loading