From a188ceacbc7998d897c2a0b3d6110499a221de47 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Tue, 2 Oct 2018 11:04:55 +0200 Subject: [PATCH] invitees --- .../OrgActionBar/OrgActionBar.test.tsx | 1 - .../app/features/users/InviteesTable.test.tsx | 32 + public/app/features/users/InviteesTable.tsx | 11 +- .../features/users/UsersActionBar.test.tsx | 51 ++ .../app/features/users/UsersListPage.test.tsx | 6 +- .../app/features/users/__mocks__/userMocks.ts | 25 + .../__snapshots__/InviteesTable.test.tsx.snap | 318 +++++++ .../UsersActionBar.test.tsx.snap | 141 +++ .../__snapshots__/UsersListPage.test.tsx.snap | 12 +- .../__snapshots__/UsersTable.test.tsx.snap | 814 +++++++++--------- 10 files changed, 987 insertions(+), 424 deletions(-) create mode 100644 public/app/features/users/InviteesTable.test.tsx create mode 100644 public/app/features/users/UsersActionBar.test.tsx create mode 100644 public/app/features/users/__snapshots__/InviteesTable.test.tsx.snap create mode 100644 public/app/features/users/__snapshots__/UsersActionBar.test.tsx.snap diff --git a/public/app/core/components/OrgActionBar/OrgActionBar.test.tsx b/public/app/core/components/OrgActionBar/OrgActionBar.test.tsx index d1edeeaa779..6b4f7d24d30 100644 --- a/public/app/core/components/OrgActionBar/OrgActionBar.test.tsx +++ b/public/app/core/components/OrgActionBar/OrgActionBar.test.tsx @@ -5,7 +5,6 @@ import OrgActionBar, { Props } from './OrgActionBar'; const setup = (propOverrides?: object) => { const props: Props = { searchQuery: '', - showLayoutMode: true, setSearchQuery: jest.fn(), linkButton: { href: 'some/url', title: 'test' }, }; diff --git a/public/app/features/users/InviteesTable.test.tsx b/public/app/features/users/InviteesTable.test.tsx new file mode 100644 index 00000000000..9aae4d765b7 --- /dev/null +++ b/public/app/features/users/InviteesTable.test.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import InviteesTable, { Props } from './InviteesTable'; +import { Invitee } from 'app/types'; +import { getMockInvitees } from './__mocks__/userMocks'; + +const setup = (propOverrides?: object) => { + const props: Props = { + invitees: [] as Invitee[], + revokeInvite: jest.fn(), + }; + + Object.assign(props, propOverrides); + + return shallow(); +}; + +describe('Render', () => { + it('should render component', () => { + const wrapper = setup(); + + expect(wrapper).toMatchSnapshot(); + }); + + it('should render invitees', () => { + const wrapper = setup({ + invitees: getMockInvitees(5), + }); + + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/public/app/features/users/InviteesTable.tsx b/public/app/features/users/InviteesTable.tsx index 82c02e607de..3157bf4fe38 100644 --- a/public/app/features/users/InviteesTable.tsx +++ b/public/app/features/users/InviteesTable.tsx @@ -7,10 +7,10 @@ export interface Props { } export default class InviteesTable extends PureComponent { - private copyRef = createRef(); + private copyUrlRef = createRef(); copyToClipboard = () => { - const node = this.copyRef.current; + const node = this.copyUrlRef.current; if (node) { node.select(); @@ -39,7 +39,12 @@ export default class InviteesTable extends PureComponent { {invitee.name}