Skip to content

Commit

Permalink
Add tests to get 100% converage
Browse files Browse the repository at this point in the history
The test added for app_logic will never happen but hey, 100 is 100.

Also added test to recent_activity for 100% coverage
  • Loading branch information
scottybollinger committed Sep 9, 2020
1 parent c57ca47 commit b5e728a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ describe('AppLogic', () => {
organization: {},
};

const expectedLogicValues = {
account: {
canCreateInvitations: true,
canCreatePersonalSources: true,
groups: ['Default', 'Cats'],
id: 'some-id-string',
isAdmin: true,
isCurated: false,
viewedOnboardingPage: true,
},
hasInitialized: true,
isFederatedAuth: false,
organization: {
defaultOrgName: 'My Organization',
name: 'ACME Donuts',
},
};

it('has expected default values', () => {
expect(AppLogic.values).toEqual(DEFAULT_VALUES);
});
Expand All @@ -30,22 +48,16 @@ describe('AppLogic', () => {
it('sets values based on passed props', () => {
AppLogic.actions.initializeAppData(DEFAULT_INITIAL_APP_DATA);

expect(AppLogic.values).toEqual(expectedLogicValues);
});

it('handles case where workplaceSearch undefined', () => {
AppLogic.actions.initializeAppData({ isFederatedAuth: false });

expect(AppLogic.values).toEqual({
account: {
canCreateInvitations: true,
canCreatePersonalSources: true,
groups: ['Default', 'Cats'],
id: 'some-id-string',
isAdmin: true,
isCurated: false,
viewedOnboardingPage: true,
},
hasInitialized: true,
isFederatedAuth: false,
organization: {
defaultOrgName: 'My Organization',
name: 'ACME Donuts',
},
...expectedLogicValues,
organization: {},
account: {},
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import React from 'react';
import { shallow } from 'enzyme';

import { EuiEmptyPrompt, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

import { RecentActivity, RecentActivityItem } from './recent_activity';

Expand Down Expand Up @@ -61,4 +62,19 @@ describe('RecentActivity', () => {
expect(wrapper.find('.activity--error__label')).toHaveLength(1);
expect(wrapper.find(EuiLink).prop('color')).toEqual('danger');
});

it('renders recent activity message for default org name', () => {
setMockValues({
organization: {
name: 'foo',
defaultOrgName: 'foo',
},
});
const wrapper = shallow(<RecentActivity />);
const emptyPrompt = wrapper.find(EuiEmptyPrompt).dive();

expect(emptyPrompt.find(FormattedMessage).prop('defaultMessage')).toEqual(
'Your organization has no recent activity'
);
});
});

0 comments on commit b5e728a

Please sign in to comment.