1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00
metamask-extension/shared/modules/security-provider.utils.test.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

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