Skip to content

Commit

Permalink
Feature/navbar (dfee#2)
Browse files Browse the repository at this point in the history
* Upgrade dependencies

* navbar component

* expose navbar component

* Add test to navbar

* Add navbar to docs

* Fix linter errors
  • Loading branch information
couds authored Dec 4, 2017
1 parent 0863ffa commit f32eb20
Show file tree
Hide file tree
Showing 68 changed files with 2,281 additions and 1,288 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/valid-expect": "error"
"jest/valid-expect": "error",
"jsx-a11y/click-events-have-key-events": 0,
"function-paren-newline": 0,
"jsx-a11y/anchor-is-valid": 0,
"object-curly-newline": 0
},
"globals": {
"document": true,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The Following componets were ported:
- Level ([Storybook](https://couds.github.io/react-bulma-components/?selectedKind=Level)) ([Docs](http://bulma.io/documentation/layout/level/))
- Media ([Storybook](https://couds.github.io/react-bulma-components/?selectedKind=Media)) ([Docs](http://bulma.io/documentation/layout/media-object/))
- Modal ([Storybook](https://couds.github.io/react-bulma-components/?selectedKind=Modal)) ([Docs](http://bulma.io/documentation/components/modal/))
- Navbar ([Storybook](https://couds.github.io/react-bulma-components/?selectedKind=Navbar)) ([Docs](https://bulma.io/documentation/components/navbar/))
- Notification ([Storybook](https://couds.github.io/react-bulma-components/?selectedKind=Notification)) ([Docs](http://bulma.io/documentation/elements/notification/))
- Progress ([Storybook](https://couds.github.io/react-bulma-components/?selectedKind=Progress)) ([Docs](http://bulma.io/documentation/elements/progress/))
- Section ([Storybook](https://couds.github.io/react-bulma-components/?selectedKind=Section)) ([Docs](http://bulma.io/documentation/layout/section/))
Expand Down
10 changes: 6 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
setupTestFrameworkScriptFile: './__test__/setup.js',
rootDir: 'src',
testMatch: ['**/*.test.js'],
coverageDirectory: '<rootDir>/../.coverage',
Expand All @@ -11,16 +12,17 @@ module.exports = {
coverageReporters: ['lcov', 'text', 'text-summary'],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
branches: 90,
functions: 90,
lines: 90,
statements: 90,
},
},
transform: {
'^.+\\.js$': 'babel-jest',
},
moduleNameMapper: {
'\\.(css|less|s(c|a)ss)$': '<rootDir>/../__mocks__/style.js',
'services(.*)$': '<rootDir>/services$1',
},
};
59 changes: 30 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"homepage": "https://github.com/couds/react-bulma-components#readme",
"dependencies": {
"bulma": "0.5.3",
"bulma": "0.6.1",
"classnames": "2.2.5"
},
"peerDependencies": {
Expand All @@ -42,16 +42,16 @@
"react-dom": "15.6.1"
},
"devDependencies": {
"@storybook/addon-actions": "3.2.10",
"@storybook/addon-info": "3.2.10",
"@storybook/addon-links": "3.2.10",
"@storybook/cli": "3.2.10",
"@storybook/react": "3.2.10",
"@storybook/addon-actions": "3.2.16",
"@storybook/addon-info": "3.2.16",
"@storybook/addon-links": "3.2.16",
"@storybook/cli": "3.2.16",
"@storybook/react": "3.2.16",
"@storybook/storybook-deployer": "2.0.0",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "8.0.0",
"babel-jest": "21.0.2",
"babel-eslint": "8.0.3",
"babel-jest": "21.2.0",
"babel-loader": "7.1.2",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-syntax-object-rest-spread": "6.13.0",
Expand All @@ -64,35 +64,36 @@
"babel-preset-react": "6.24.1",
"babel-register": "6.26.0",
"chai": "4.1.2",
"coveralls": "2.13.1",
"coveralls": "3.0.0",
"css-loader": "0.28.7",
"enzyme": "2.9.1",
"eslint": "4.7.2",
"eslint-config-airbnb": "15.1.0",
"enzyme": "3.2.0",
"enzyme-adapter-react-16": "1.1.0",
"eslint": "4.12.1",
"eslint-config-airbnb": "16.1.0",
"eslint-import-resolver-webpack": "0.8.3",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jest": "21.1.0",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jest": "21.3.2",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-react": "7.3.0",
"extract-text-webpack-plugin": "3.0.0",
"file-loader": "0.11.2",
"jest": "21.1.0",
"jsdom": "11.2.0",
"node-sass": "4.5.3",
"eslint-plugin-react": "7.5.1",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"jest": "21.2.1",
"jsdom": "11.5.1",
"node-sass": "4.7.2",
"nodemon": "1.12.1",
"null-loader": "0.1.1",
"optimize-css-assets-webpack-plugin": "3.2.0",
"postcss-loader": "2.0.6",
"postcss-loader": "2.0.9",
"progress-bar-webpack-plugin": "1.10.0",
"prop-types": "15.5.10",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-test-renderer": "15.6.1",
"prop-types": "15.6.0",
"react": "16.2.0",
"react-dom": "16.2.0",
"react-test-renderer": "16.2.0",
"sass-loader": "6.0.6",
"source-map-support": "0.4.18",
"style-loader": "0.18.2",
"source-map-support": "0.5.0",
"style-loader": "0.19.0",
"toolbox-loader": "0.0.3",
"webpack": "3.6.0",
"webpack-bundle-analyzer": "2.9.0"
"webpack": "3.9.1",
"webpack-bundle-analyzer": "2.9.1"
}
}
1 change: 1 addition & 0 deletions src/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Object {
"Loader": [Function],
"Media": [Function],
"Modal": [Function],
"Navbar": [Function],
"Notification": [Function],
"Progress": [Function],
"Section": [Function],
Expand Down
5 changes: 5 additions & 0 deletions src/__test__/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require('raf/polyfill');
const Adapter = require('enzyme-adapter-react-16');
const enzyme = require('enzyme');

enzyme.configure({ adapter: new Adapter() });
16 changes: 4 additions & 12 deletions src/components/box/__test__/box.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,19 @@ describe('Box component', () => {
expect(Box).toMatchSnapshot();
});
it('Should have box classname', () => {
const component = renderer.create(
<Box>Facebook</Box>,
);
const component = renderer.create(<Box>Facebook</Box>);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should concat Bulma class with classes in props', () => {
const component = renderer.create(
<Box className="other-class test">Facebook</Box>,
);
const component = renderer.create(<Box className="other-class test">Facebook</Box>);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should render as an html section', () => {
const component = renderer.create(
<Box renderAs="section">This should be a section</Box>,
);
const component = renderer.create(<Box renderAs="section">This should be a section</Box>);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should have custom inline styles', () => {
const component = renderer.create(
<Box renderAs="section" style={{ width: 200, zIndex: 1 }}>This should be a section with custom styles</Box>,
);
const component = renderer.create(<Box renderAs="section" style={{ width: 200, zIndex: 1 }}>This should be a section with custom styles</Box>);
expect(component.toJSON()).toMatchSnapshot();
});
});
40 changes: 16 additions & 24 deletions src/components/breadcrumb/__test__/breadcrumb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ describe('Breadcrumb component', () => {
console.warn.mockRestore();
});
it('Should be a Breadcrumb', () => {
const component = renderer.create(
<Breadcrumb
items={[
const component = renderer.create(<Breadcrumb
items={[
{
url: '/',
name: 'Home',
Expand All @@ -34,16 +33,14 @@ describe('Breadcrumb component', () => {
active: true,
},
]}
/>,
);
/>);
expect(component.toJSON()).toMatchSnapshot();
});
[null, 'arrow', 'dot', 'bullet', 'succeeds'].map(separator => (
it(`should use separator ${separator}`, () => {
const component = renderer.create(
<Breadcrumb
separator={separator}
items={[
const component = renderer.create(<Breadcrumb
separator={separator}
items={[
{
name: 'Storybook',
url: '#1',
Expand All @@ -56,16 +53,14 @@ describe('Breadcrumb component', () => {
active: true,
},
]}
/>,
);
/>);
expect(component.toJSON()).toMatchSnapshot();
})
));
it('Should throw a warning that hrefAttr is not defined', () => {
const component = renderer.create(
<Breadcrumb
renderAs={Anchor}
items={[
const component = renderer.create(<Breadcrumb
renderAs={Anchor}
items={[
{
url: '/',
name: 'Home',
Expand All @@ -80,17 +75,15 @@ describe('Breadcrumb component', () => {
active: true,
},
]}
/>,
);
/>);
expect(global.console.warn).toBeCalled();
expect(component.toJSON()).toMatchSnapshot();
});
it('Should use inline style and custom size', () => {
const component = renderer.create(
<Breadcrumb
style={{ marginTop: 10 }}
size="large"
items={[
const component = renderer.create(<Breadcrumb
style={{ marginTop: 10 }}
size="large"
items={[
{
url: '/',
name: 'Home',
Expand All @@ -105,8 +98,7 @@ describe('Breadcrumb component', () => {
active: true,
},
]}
/>,
);
/>);
expect(component.toJSON()).toMatchSnapshot();
});
});
12 changes: 5 additions & 7 deletions src/components/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ Breadcrumb.propTypes = {
separator: PropTypes.oneOf(['arrow', 'bullet', 'dot', 'succeeds']),
size: PropTypes.oneOf(['small', 'medium', 'large']),
align: PropTypes.oneOf(['right', 'center']),
items: PropTypes.arrayOf(
PropTypes.shape({
url: PropTypes.string.isRequired,
active: PropTypes.bool,
name: PropTypes.node,
}),
),
items: PropTypes.arrayOf(PropTypes.shape({
url: PropTypes.string.isRequired,
active: PropTypes.bool,
name: PropTypes.node,
})),
renderAs: PropTypes.oneOfType([
PropTypes.oneOf(['a']),
PropTypes.func,
Expand Down
46 changes: 12 additions & 34 deletions src/components/button/__test__/button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,84 +18,62 @@ Link.propTypes = {

describe('Button component', () => {
it('Should be a default Button', () => {
const component = renderer.create(
<Button href="http://google.com" />,
);
const component = renderer.create(<Button href="http://google.com" />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should be a Primary Button', () => {
const component = renderer.create(
<Button color="primary" />,
);
const component = renderer.create(<Button color="primary" />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should be a Large Primary Button', () => {
const component = renderer.create(
<Button color="primary" size="large" />,
);
const component = renderer.create(<Button color="primary" size="large" />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should render as a static Button', () => {
const component = renderer.create(
<Button static color="primary" />,
);
const component = renderer.create(<Button static color="primary" />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should render as a html button', () => {
const component = renderer.create(
<Button renderAs="button" color="danger" />,
);
const component = renderer.create(<Button renderAs="button" color="danger" />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should render as a React element link with custom href', () => {
const component = renderer.create(
<Button renderAs={Link} href="http://google.com" hrefAttr="to" color="danger" >
TEST
</Button>,
);
</Button>);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should throw a console.error if no hrefAttr is defined when renderAs different as A and href attr is defined', () => {
console.error = jest.genMockFn();
renderer.create(
<Button renderAs={Link} href="http://google.com" color="danger" >
TEST
</Button>,
);
</Button>);
expect(console.error).toHaveBeenCalled();
console.error.mockRestore();
});
it('Should render be disabled', () => {
const component = renderer.create(
<Button disabled />,
);
const component = renderer.create(<Button disabled />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should be a submit form button', () => {
const component = renderer.create(
<Button submit />,
);
const component = renderer.create(<Button submit />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should be a reset form button', () => {
const component = renderer.create(
<Button reset />,
);
const component = renderer.create(<Button reset />);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should have a Click listener', () => {
const onClick = jest.fn();
const component = shallow(
<Button onClick={onClick} />,
);
const component = shallow(<Button onClick={onClick} />);
component.simulate('click');
expect(onClick).toHaveBeenCalledTimes(1);
});
it('Should have a call default onClick is no listener is set', () => {
const spy = jest.spyOn(Button.defaultProps, 'onClick');
const component = shallow(
<Button />,
);
const component = shallow(<Button />);
component.simulate('click');
component.simulate('click');
expect(spy).toHaveBeenCalledTimes(2);
Expand Down
Loading

0 comments on commit f32eb20

Please sign in to comment.