Skip to content

Commit

Permalink
created tests for inputgroupaddon
Browse files Browse the repository at this point in the history
  • Loading branch information
hertweckhr1 committed Oct 11, 2019
1 parent 837f08b commit 3e9dfd3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/InputGroup/InputGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,21 +295,5 @@ describe('<InputGroup />', () => {
element.find('input').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});

test('should allow props to be spread to the InputGroup component for type number\'s up button element', () => {
const element = mount(<InputGroup inputType='number' numberUpButtonProps={{ 'data-sample': 'Sample' }} />);

expect(
element.find('button.sap-icon--slim-arrow-up').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});

test('should allow props to be spread to the InputGroup component for type number\'s down button element', () => {
const element = mount(<InputGroup inputType='number' numberDownButtonProps={{ 'data-sample': 'Sample' }} />);

expect(
element.find('button.sap-icon--slim-arrow-down').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
});
});
43 changes: 43 additions & 0 deletions src/InputGroup/InputGroupAddon.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import InputGroupAddon from './InputGroupAddon';
import { mount } from 'enzyme';
import React from 'react';
import renderer from 'react-test-renderer';


describe('<InputGroupAddon />', () => {
const inputGroupAddon = (
<InputGroupAddon addon='$' />
);

test('create list group item actions', () => {
let component = renderer.create(inputGroupAddon);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

describe('Prop spreading', () => {
test('should allow props to be spread to the ListGroupItemActions component', () => {
const element = mount(<InputGroupAddon data-sample='Sample' />);

expect(
element.getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
});

test('should allow props to be spread to the InputGroup component for type number\'s up button element', () => {
const element = mount(<InputGroupAddon inputType='number' numberUpButtonProps={{ 'data-sample': 'Sample' }} />);

expect(
element.find('button.sap-icon--slim-arrow-up').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});

test('should allow props to be spread to the InputGroup component for type number\'s down button element', () => {
const element = mount(<InputGroupAddon inputType='number' numberDownButtonProps={{ 'data-sample': 'Sample' }} />);

expect(
element.find('button.sap-icon--slim-arrow-down').getDOMNode().attributes['data-sample'].value
).toBe('Sample');
});
});
9 changes: 9 additions & 0 deletions src/InputGroup/__snapshots__/InputGroupAddon.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<InputGroupAddon /> create list group item actions 1`] = `
<span
className="fd-input-group__addon"
>
$
</span>
`;

0 comments on commit 3e9dfd3

Please sign in to comment.