Add tests for 'Button' component

Close #583
This commit is contained in:
Andrew Kennedy
2017-08-01 11:26:16 -07:00
committed by Nicolas Gallagher
parent 8d80885f5d
commit 17d723559d

View File

@@ -1,5 +1,30 @@
/* eslint-env jasmine, jest */
import React from 'react';
import Button from '..';
import { mount, shallow } from 'enzyme';
const findNativeButton = wrapper => wrapper.getDOMNode();
describe('components/Button', () => {
test.skip('NO TEST COVERAGE', () => {});
test('prop "color"', () => {
const onPress = () => {};
const color = 'blue';
const button = findNativeButton(mount(<Button color={color} onPress={onPress} title="" />));
expect(button.style.backgroundColor).toEqual(color);
});
test('prop "onPress"', () => {
const onPress = jest.fn();
const component = shallow(<Button onPress={onPress} title="" />);
component.simulate('press');
expect(onPress).toHaveBeenCalled();
});
test('prop "title"', () => {
const onPress = () => {};
const text = 'Click me';
const component = mount(<Button onPress={onPress} title={text} />);
expect(component.text()).toEqual(text);
});
});