mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-21 17:37:01 +01:00
34375a57e5
* security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { SECURITY_PROVIDER_MESSAGE_SEVERITY } from '../constants/security-provider';
|
|
import { isSuspiciousResponse } from './security-provider.utils';
|
|
|
|
describe('security-provider util', () => {
|
|
describe('isSuspiciousResponse', () => {
|
|
it('should return false if the response does not exist', () => {
|
|
const result = isSuspiciousResponse(undefined);
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it('should return false when flagAsDangerous exists and is not malicious', () => {
|
|
const result = isSuspiciousResponse({
|
|
flagAsDangerous: SECURITY_PROVIDER_MESSAGE_SEVERITY.NOT_MALICIOUS,
|
|
});
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it('should return true when flagAsDangerous exists and is malicious or not safe', () => {
|
|
const result = isSuspiciousResponse({
|
|
flagAsDangerous: SECURITY_PROVIDER_MESSAGE_SEVERITY.NOT_SAFE,
|
|
});
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
it('should return true if the response exists but is empty', () => {
|
|
const result = isSuspiciousResponse({});
|
|
expect(result).toBeTruthy();
|
|
});
|
|
});
|
|
});
|