Skip to content

Commit

Permalink
feat: Create Buttons component
Browse files Browse the repository at this point in the history
  • Loading branch information
b0gok committed Sep 13, 2016
1 parent 0b86859 commit 1f78c6c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/elements/buttons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import React from 'react';

import filter from '../filter';
import Div from '../commons/div';

const defaultClassName = 'ui buttons';
const componentName = 'Buttons';

const Buttons = new filter(Div)
.classGenerator(defaultClassName)
.getComposeComponent(componentName);

export default Buttons;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export Title from './commons/title';

// elements
export Button from './elements/button';
export Buttons from './elements/buttons';
export Container from './elements/container';
export Divider from './elements/divider';
export Flag from './elements/flag';
Expand Down
40 changes: 40 additions & 0 deletions test/__tests__/elements/Buttons-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

import ReactDOM from 'react-dom';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {Buttons} from '../../../src/index';

describe('Buttons', () => {
it('should have .ui.buttons class by default', () => {
let instance = TestUtils.renderIntoDocument(
<Buttons></Buttons>
);

expect(ReactDOM.findDOMNode(instance).className).toMatch('ui');
expect(ReactDOM.findDOMNode(instance).className).toMatch('buttons');
});

it('should have child by default', () => {
let instance = TestUtils.renderIntoDocument(
<Buttons>123</Buttons>
);

expect(ReactDOM.findDOMNode(instance).textContent).toEqual('123');
});

it('should have custom class with custom className', () => {
let instance = TestUtils.renderIntoDocument(
<Buttons className="custom"></Buttons>
);

expect(ReactDOM.findDOMNode(instance).className).toMatch('custom');
});

it('should display Buttons name', () => {
let Component = (
<Buttons></Buttons>
);

expect(Component.type.displayName).toMatch('Buttons');
});
});

0 comments on commit 1f78c6c

Please sign in to comment.