Skip to content

Commit

Permalink
Adds some syntax and readibility nits comming from pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dasansol92 committed Jun 1, 2021
1 parent eaae47d commit a13e57e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,21 @@ describe('Fleet event filters card', () => {
}
return component;
};
afterEach(() => {
EventFiltersHttpServiceMock.mockReset();
});
beforeEach(() => {
promise = Promise.resolve(summary);
addDanger = jest.fn();
});
beforeAll(() => {
useToastsMock.mockImplementation(() => {
return {
addDanger,
};
});
});
it('should renders correctly', async () => {
beforeEach(() => {
promise = Promise.resolve(summary);
addDanger = jest.fn();
});
afterEach(() => {
EventFiltersHttpServiceMock.mockReset();
});
it('should render correctly', async () => {
EventFiltersHttpServiceMock.mockImplementationOnce(() => {
return {
getSummary: () => jest.fn(() => promise),
Expand All @@ -100,7 +100,7 @@ describe('Fleet event filters card', () => {
expect(component.getByText('Event Filters')).not.toBeNull();
expect(component.getByText('Manage event filters')).not.toBeNull();
});
it('should renders an error when api call fails', async () => {
it('should render an error toast when api call fails', async () => {
expect(addDanger).toBeCalledTimes(0);
promise = Promise.reject(new Error('error test'));
EventFiltersHttpServiceMock.mockImplementationOnce(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const FleetEventFiltersCard = memo<PackageCustomExtensionComponentProps>(
const fetchStats = async () => {
try {
const summary = await eventFiltersApi.getSummary();
if (isMounted.current) setStats(summary);
if (isMounted.current) {
setStats(summary);
}
} catch (error) {
toasts.addDanger(
i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ describe('Fleet trusted apps card', () => {
return component;
};

afterEach(() => {
TrustedAppsHttpServiceMock.mockReset();
});
beforeEach(() => {
promise = Promise.resolve(summary);
addDanger = jest.fn();
});
beforeAll(() => {
useToastsMock.mockImplementation(() => {
return {
addDanger,
};
});
});
it('should renders correctly', async () => {
beforeEach(() => {
promise = Promise.resolve(summary);
addDanger = jest.fn();
});
afterEach(() => {
TrustedAppsHttpServiceMock.mockReset();
});
it('should render correctly', async () => {
TrustedAppsHttpServiceMock.mockImplementationOnce(() => {
return {
getTrustedAppsSummary: () => jest.fn(() => promise),
Expand All @@ -101,7 +101,7 @@ describe('Fleet trusted apps card', () => {
expect(component.getByText('Trusted Applications')).not.toBeNull();
expect(component.getByText('Manage trusted applications')).not.toBeNull();
});
it('should renders an error when api call fails', async () => {
it('should render an error toast when api call fails', async () => {
expect(addDanger).toBeCalledTimes(0);
promise = Promise.reject(new Error('error test'));
TrustedAppsHttpServiceMock.mockImplementationOnce(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const FleetTrustedAppsCard = memo<PackageCustomExtensionComponentProps>((
const fetchStats = async () => {
try {
const response = await trustedAppsApi.getTrustedAppsSummary();
if (isMounted) setStats(response);
if (isMounted) {
setStats(response);
}
} catch (error) {
toasts.addDanger(
i18n.translate(
Expand Down

0 comments on commit a13e57e

Please sign in to comment.