1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +02:00
metamask-extension/shared/modules/security-provider.utils.test.ts
Ariella Vu 34375a57e5
Security Provider cleanup (#19694)
* 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
2023-06-23 20:08:22 +02:00

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();
});
});
});