Skip to content

Commit

Permalink
Migrate UserRow component
Browse files Browse the repository at this point in the history
  • Loading branch information
scottybollinger committed Sep 1, 2020
1 parent da40c34 commit ae71642
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { UserRow } from './user_row';
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallow } from 'enzyme';

import { EuiTableRow } from '@elastic/eui';

import { users } from '../../../__mocks__/users.mock';

import { UserRow } from './';

describe('SourcesTable', () => {
it('renders', () => {
const wrapper = shallow(<UserRow user={users[0]} />);

expect(wrapper.find(EuiTableRow)).toHaveLength(1);
expect(wrapper.find('span')).toHaveLength(0);
});

it('renders with email visible', () => {
const wrapper = shallow(<UserRow user={users[0]} showEmail />);

expect(wrapper.find('span')).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';

import { EuiTableRow, EuiTableRowCell } from '@elastic/eui';

import { IUser } from '../../../types';

interface IUserRowProps {
user: IUser;
showEmail?: boolean;
}

export const UserRow: React.FC<IUserRowProps> = ({ user: { name, email }, showEmail }) => (
<EuiTableRow>
<EuiTableRowCell>{name}</EuiTableRowCell>
<EuiTableRowCell>{showEmail && <span>{email}</span>}</EuiTableRowCell>
</EuiTableRow>
);

0 comments on commit ae71642

Please sign in to comment.