Skip to content

Commit

Permalink
Covered more code with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsekulic committed Feb 21, 2023
1 parent 85db441 commit f25e7c0
Showing 1 changed file with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,71 @@ describe('Security Provider Banner Message', () => {

expect(link.closest('a')).toHaveAttribute('href', 'https://opensea.io/');
});

it('should render SecurityProviderBannerMessage component properly, with predefined reason message, when a request is malicious and there is no reason given', () => {
const securityProviderResponse = {
flagAsDangerous: SECURITY_PROVIDER_MESSAGE_SEVERITIES.MALICIOUS,
reason: '',
reason_header: 'Some reason header...',
};

const reason = 'The security provider has not shared additional details';

const { getByText } = renderWithProvider(
<SecurityProviderBannerMessage
securityProviderResponse={securityProviderResponse}
/>,
store,
);

expect(
getByText(securityProviderResponse.reason_header),
).toBeInTheDocument();
expect(getByText(reason)).toBeInTheDocument();
expect(getByText(thisIsBasedOnText)).toBeInTheDocument();
});

it('should render SecurityProviderBannerMessage component properly, with predefined reason_header message, when a request is malicious and there is no reason header given', () => {
const securityProviderResponse = {
flagAsDangerous: SECURITY_PROVIDER_MESSAGE_SEVERITIES.MALICIOUS,
reason: 'Some reason...',
reason_header: '',
};

const reasonHeader = 'Request flagged as malicious';

const { getByText } = renderWithProvider(
<SecurityProviderBannerMessage
securityProviderResponse={securityProviderResponse}
/>,
store,
);

expect(getByText(reasonHeader)).toBeInTheDocument();
expect(getByText(securityProviderResponse.reason)).toBeInTheDocument();
expect(getByText(thisIsBasedOnText)).toBeInTheDocument();
});

it('should render SecurityProviderBannerMessage component properly, with predefined reason and reason_header messages, when a request is malicious and there are no reason and reason header given', () => {
const securityProviderResponse = {
flagAsDangerous: SECURITY_PROVIDER_MESSAGE_SEVERITIES.MALICIOUS,
reason: '',
reason_header: '',
};

const reasonHeader = 'Request flagged as malicious';

const reason = 'The security provider has not shared additional details';

const { getByText } = renderWithProvider(
<SecurityProviderBannerMessage
securityProviderResponse={securityProviderResponse}
/>,
store,
);

expect(getByText(reasonHeader)).toBeInTheDocument();
expect(getByText(reason)).toBeInTheDocument();
expect(getByText(thisIsBasedOnText)).toBeInTheDocument();
});
});

0 comments on commit f25e7c0

Please sign in to comment.