Skip to content

Commit

Permalink
Restructure components. Scaffold tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Allen committed Apr 1, 2019
1 parent d624d87 commit c12e81f
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { shallow, mount } from 'enzyme'
import React from 'react'
import FieldGuideButton from './FieldGuideButton'
import FieldGuideContainer from './FieldGuideContainer'

describe('Component > FieldGuideButton', function () {
it('should render without crashing', function () {
shallow(<FieldGuideButton />)
})
describe('Component > FieldGuideContainer', function () {

it('should have an ARIA label', function () {
const wrapper = mount(<FieldGuideButton />)
expect(wrapper.find('button').prop('aria-label')).to.equal('Open Field Guide')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { inject, observer } from 'mobx-react'
import FieldGuideItems from './FieldGuideItems'
import FieldGuideItem from './FieldGuideItem'
import FieldGuideItems from './components/FieldGuideItems'
import FieldGuideItem from './components/FieldGuideItem'

const StyledBox = styled(Box)`
max-height: 415px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import zooTheme from '@zooniverse/grommet-theme'
import { Button, Box, Heading, Text } from 'grommet'
import { Button, Box } from 'grommet'
import { FormPrevious } from 'grommet-icons'
import styled from 'styled-components'
import React from 'react'
import { observable } from 'mobx'
import { Markdownz, Media } from '@zooniverse/react-components'
import PropTypes from 'prop-types'
import { inject, observer, PropTypes as MobXPropTypes } from 'mobx-react'
import counterpart from 'counterpart'
import en from './locales/en'

counterpart.registerTranslations('en', en)

const FieldGuideItemHeader = styled(Box)`
/* display: flex;
flex-direction: row; */
> h3 {
margin: 0;
}
Expand All @@ -36,7 +34,7 @@ class FieldGuideItem extends React.Component {
<Box>
<FieldGuideItemHeader align='center' direction='row'>
<Button
a11yTitle="Go back to Field Guide items list"
a11yTitle={counterpart("FieldGuideItem.ariaTitle")}
icon={<FormPrevious />}
onClick={() => setActiveItem()}
plain
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './FieldGuideItem'
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FieldGuideItemButton extends React.Component {
const label = <ButtonLabel icons={icons} item={item} />
return (
<StyledButton
a11yTitle={counterpart('FieldGuideItem.ariaTitle', { title: item.title })}
a11yTitle={counterpart('FieldGuideItemButton.ariaTitle', { title: item.title })}
className={className}
key={item.title} // Is this secure?
label={label}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './FieldGuideItems'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"FieldGuideItem": {
"FieldGuideItemButton": {
"ariaTitle": "Select %(title)s"
}
}

0 comments on commit c12e81f

Please sign in to comment.