diff --git a/packages/message-manager/src/AbstractMessageManager.test.ts b/packages/message-manager/src/AbstractMessageManager.test.ts index da11beb542..5aadef1b8c 100644 --- a/packages/message-manager/src/AbstractMessageManager.test.ts +++ b/packages/message-manager/src/AbstractMessageManager.test.ts @@ -51,7 +51,7 @@ const messageIdMock = 'message-id-mocked'; const fromMock = '0xc38bf1ad06ef69f0c04e29dbeb4152b4175f0a8d'; describe('AbstractTestManager', () => { - it('should set default state', () => { + it('sets default state', () => { const controller = new AbstractTestManager(); expect(controller.state).toStrictEqual({ unapprovedMessages: {}, @@ -59,12 +59,12 @@ describe('AbstractTestManager', () => { }); }); - it('should set default config', () => { + it('sets default config', () => { const controller = new AbstractTestManager(); expect(controller.config).toStrictEqual({}); }); - it('should add a valid message', async () => { + it('adds a valid message', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -88,7 +88,7 @@ describe('AbstractTestManager', () => { expect(message.type).toBe(messageType); }); - it('should get all messages', async () => { + it('retrieves all messages', async () => { const controller = new AbstractTestManager(); const message = { id: messageId, @@ -153,7 +153,7 @@ describe('AbstractTestManager', () => { expect(message.securityProviderResponse).toBe(securityProviderResponseMock); }); - it('should reject a message', async () => { + it('rejects a message', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -173,7 +173,7 @@ describe('AbstractTestManager', () => { expect(message.status).toBe('rejected'); }); - it('should sign a message', async () => { + it('signs a message', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -219,7 +219,7 @@ describe('AbstractTestManager', () => { expect(message.status).toBe('test-status'); }); - it('should set a status to inProgress', async () => { + it('sets a status to inProgress', async () => { const controller = new AbstractTestManager( undefined, undefined, @@ -244,7 +244,7 @@ describe('AbstractTestManager', () => { expect(message.status).toBe('inProgress'); }); - it('should get correct unapproved messages', async () => { + it('gets correct unapproved messages', async () => { const firstMessageData = [ { name: 'Message', @@ -293,7 +293,7 @@ describe('AbstractTestManager', () => { }); }); - it('should approve typed message', async () => { + it('approves typed message', async () => { const controller = new AbstractTestManager(); const firstMessage = { from: '0xfoO', data: typedMessage }; const version = 'V1'; @@ -318,7 +318,7 @@ describe('AbstractTestManager', () => { }); describe('setMessageStatus', () => { - it('should set the given message status', async () => { + it('sets the given message status', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -335,7 +335,7 @@ describe('AbstractTestManager', () => { expect(messageAfter?.status).toBe('newstatus'); }); - it('should throw an error if message is not found', () => { + it('throws an error if message is not found', () => { const controller = new AbstractTestManager(); expect(() => controller.setMessageStatus(messageId, 'newstatus')).toThrow( @@ -370,7 +370,7 @@ describe('AbstractTestManager', () => { }); describe('setMetadata', () => { - it('should set the given message metadata', async () => { + it('sets the given message metadata', async () => { const controller = new AbstractTestManager(); await controller.addMessage({ id: messageId, @@ -388,7 +388,7 @@ describe('AbstractTestManager', () => { expect(messageAfter?.metadata).toStrictEqual({ foo: 'bar' }); }); - it('should throw an error if message is not found', () => { + it('throws an error if message is not found', () => { const controller = new AbstractTestManager(); expect(() => controller.setMetadata(messageId, { foo: 'bar' })).toThrow( diff --git a/packages/message-manager/src/PersonalMessageManager.test.ts b/packages/message-manager/src/PersonalMessageManager.test.ts index c7a082c848..df60ba1e47 100644 --- a/packages/message-manager/src/PersonalMessageManager.test.ts +++ b/packages/message-manager/src/PersonalMessageManager.test.ts @@ -31,18 +31,18 @@ describe('PersonalMessageManager', () => { detectSIWEMock.mockReturnValue(siweMockNotFound); }); - it('should set default state', () => { + it('sets default state', () => { expect(controller.state).toStrictEqual({ unapprovedMessages: {}, unapprovedMessagesCount: 0, }); }); - it('should set default config', () => { + it('sets default config', () => { expect(controller.config).toStrictEqual({}); }); - it('should add a valid message', async () => { + it('adds a valid message', async () => { const messageId = '1'; const from = '0x0123'; const messageData = '0x123'; @@ -71,7 +71,7 @@ describe('PersonalMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should add a valid unapproved message', async () => { + it('adds a valid unapproved message', async () => { const messageStatus = 'unapproved'; const messageType = 'personal_sign'; const messageParams = { @@ -102,7 +102,7 @@ describe('PersonalMessageManager', () => { expect(message.securityAlertResponse?.reason).toBe('reason'); }); - it('should throw when adding invalid message', async () => { + it('throws when adding invalid message', async () => { const from = 'foo'; const messageData = '0x123'; await expect( @@ -115,7 +115,7 @@ describe('PersonalMessageManager', () => { ); }); - it('should get correct unapproved messages', async () => { + it('gets correct unapproved messages', async () => { const firstMessage = { id: '1', messageParams: { from: '0x1', data: '0x123' }, @@ -139,7 +139,7 @@ describe('PersonalMessageManager', () => { }); }); - it('should approve message', async () => { + it('approves message', async () => { const firstMessage = { from: fromMock, data: '0x123' }; const messageId = await controller.addUnapprovedMessage(firstMessage); const messageParams = await controller.approveMessage({ @@ -154,7 +154,7 @@ describe('PersonalMessageManager', () => { expect(message.status).toBe('approved'); }); - it('should set message status signed', async () => { + it('sets message status signed', async () => { const firstMessage = { from: fromMock, data: '0x123' }; const rawSig = '0x5f7a0'; const messageId = await controller.addUnapprovedMessage(firstMessage); @@ -168,7 +168,7 @@ describe('PersonalMessageManager', () => { expect(message.status).toBe('signed'); }); - it('should reject message', async () => { + it('rejects message', async () => { const firstMessage = { from: fromMock, data: '0x123' }; const messageId = await controller.addUnapprovedMessage(firstMessage); controller.rejectMessage(messageId); @@ -179,7 +179,7 @@ describe('PersonalMessageManager', () => { expect(message.status).toBe('rejected'); }); - it('should add message including Ethereum sign in data', async () => { + it('adds message including Ethereum sign in data', async () => { detectSIWEMock.mockReturnValue(siweMockFound); const firstMessage = { from: fromMock, data: '0x123' }; const messageId = await controller.addUnapprovedMessage(firstMessage); diff --git a/packages/message-manager/src/TypedMessageManager.test.ts b/packages/message-manager/src/TypedMessageManager.test.ts index 99539ce645..846ad25186 100644 --- a/packages/message-manager/src/TypedMessageManager.test.ts +++ b/packages/message-manager/src/TypedMessageManager.test.ts @@ -61,18 +61,18 @@ describe('TypedMessageManager', () => { ); }); - it('should set default state', () => { + it('sets default state', () => { expect(controller.state).toStrictEqual({ unapprovedMessages: {}, unapprovedMessagesCount: 0, }); }); - it('should set default config', () => { + it('sets default config', () => { expect(controller.config).toStrictEqual({}); }); - it('should add a valid message', async () => { + it('adds a valid message', async () => { const messageId = '1'; const from = '0x0123'; const messageTime = Date.now(); @@ -101,7 +101,7 @@ describe('TypedMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should throw when adding a valid unapproved message when getCurrentChainId is undefined', async () => { + it('throws when adding a valid unapproved message when getCurrentChainId is undefined', async () => { controller = new TypedMessageManager(); const version = 'V3'; const messageData = JSON.stringify(typedMessageV3V4); @@ -116,7 +116,7 @@ describe('TypedMessageManager', () => { ).rejects.toThrow('Current chainId cannot be null or undefined.'); }); - it('should add a valid unapproved message', async () => { + it('adds a valid unapproved message', async () => { const messageStatus = 'unapproved'; const messageType = 'eth_signTypedData'; const version = 'version'; @@ -150,7 +150,7 @@ describe('TypedMessageManager', () => { expect(message.securityAlertResponse?.reason).toBe('reason'); }); - it('should add a valid V3 unapproved message as a JSON-parseable string', async () => { + it('adds a valid V3 unapproved message as a JSON-parseable string', async () => { getCurrentChainIdStub.mockImplementation(() => 1); const messageStatus = 'unapproved'; const messageType = 'eth_signTypedData'; @@ -178,7 +178,7 @@ describe('TypedMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should add a valid V3 unapproved message as an object', async () => { + it('adds a valid V3 unapproved message as an object', async () => { getCurrentChainIdStub.mockImplementation(() => 1); const messageStatus = 'unapproved'; const messageType = 'eth_signTypedData'; @@ -206,7 +206,7 @@ describe('TypedMessageManager', () => { expect(message.type).toBe(messageType); }); - it('should throw when adding invalid legacy typed message', async () => { + it('throws when adding invalid legacy typed message', async () => { const from = '0xc38bf1ad06ef69f0c04e29dbeb4152b4175f0a8d'; const messageData = '0x879'; const version = 'V1'; @@ -222,7 +222,7 @@ describe('TypedMessageManager', () => { ).rejects.toThrow('Invalid message "data":'); }); - it('should throw when adding invalid typed message', async () => { + it('throws when adding invalid typed message', async () => { const mockGetChainId = jest.fn(); const from = '0xc38bf1ad06ef69f0c04e29dbeb4152b4175f0a8d'; const messageData = typedMessage; @@ -258,7 +258,7 @@ describe('TypedMessageManager', () => { expect(mockGetChainId).toHaveBeenCalled(); }); - it('should get correct unapproved messages', async () => { + it('gets correct unapproved messages', async () => { const firstMessageData = [ { name: 'Message', @@ -306,7 +306,7 @@ describe('TypedMessageManager', () => { }); }); - it('should approve typed message', async () => { + it('approves typed message', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; @@ -330,7 +330,7 @@ describe('TypedMessageManager', () => { expect(message.status).toBe('approved'); }); - it('should set message status signed', async () => { + it('sets message status signed', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; @@ -349,7 +349,7 @@ describe('TypedMessageManager', () => { expect(message.status).toBe('signed'); }); - it('should reject message', async () => { + it('rejects message', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; @@ -366,7 +366,7 @@ describe('TypedMessageManager', () => { expect(message.status).toBe('rejected'); }); - it('should set message status errored', async () => { + it('sets message status errored', async () => { const messageData = typedMessage; const firstMessage = { from: fromMock, data: messageData }; const version = 'V1'; diff --git a/packages/message-manager/src/utils.test.ts b/packages/message-manager/src/utils.test.ts index a85ff2e1a6..e5029a6baf 100644 --- a/packages/message-manager/src/utils.test.ts +++ b/packages/message-manager/src/utils.test.ts @@ -15,7 +15,7 @@ describe('utils', () => { }); describe('validateSignMessageData', () => { - it('should throw if no from address', () => { + it('throws if no from address', () => { expect(() => util.validateSignMessageData({ data: '0x879a05', @@ -25,7 +25,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '01'; expect(() => util.validateSignMessageData({ @@ -37,7 +37,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if from address type is invalid', () => { const from = 123; expect(() => util.validateSignMessageData({ @@ -49,7 +49,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if no data', () => { + it('throws if no data', () => { expect(() => util.validateSignMessageData({ data: '0x879a05', @@ -59,7 +59,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid tyoe data', () => { + it('throws if data type is invalid', () => { expect(() => util.validateSignMessageData({ data: 123, @@ -72,7 +72,7 @@ describe('utils', () => { }); describe('validateTypedMessageDataV1', () => { - it('should throw if no from address legacy', () => { + it('throws if no from address legacy', () => { expect(() => util.validateTypedSignMessageDataV1({ data: [], @@ -82,7 +82,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '3244e191f1b4903970224322180f1'; expect(() => util.validateTypedSignMessageDataV1({ @@ -94,7 +94,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if from address type is invalid', () => { const from = 123; expect(() => util.validateTypedSignMessageDataV1({ @@ -106,7 +106,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if incorrect data', () => { + it('throws if data is incorrect', () => { expect(() => util.validateTypedSignMessageDataV1({ data: '0x879a05', @@ -117,7 +117,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if no data', () => { + it('throws if no data', () => { expect(() => util.validateTypedSignMessageDataV1({ data: '0x879a05', @@ -128,7 +128,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if invalid type data', () => { + it('throws if invalid type data', () => { expect(() => util.validateTypedSignMessageDataV1({ data: [], @@ -144,7 +144,7 @@ describe('utils', () => { const dataTyped = '{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":1,"verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","wallet":"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},"contents":"Hello, Bob!"}}'; const mockedCurrentChainId = toHex(1); - it('should throw if no from address', () => { + it('throws if no from address', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -157,7 +157,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '3244e191f1b4903970224322180f1fb'; expect(() => util.validateTypedSignMessageDataV3V4( @@ -172,7 +172,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if invalid type from address', () => { const from = 123; expect(() => util.validateTypedSignMessageDataV3V4( @@ -187,7 +187,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if array data', () => { + it('throws if array data', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -201,7 +201,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if no array data', () => { + it('throws if no array data', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -214,7 +214,7 @@ describe('utils', () => { ).toThrow('Invalid message "data":'); }); - it('should throw if no json valid data', () => { + it('throws if no json valid data', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -228,7 +228,7 @@ describe('utils', () => { ).toThrow('Data must be passed as a valid JSON string.'); }); - it('should throw if current chain id is not present', () => { + it('throws if current chain id is not present', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -242,7 +242,7 @@ describe('utils', () => { ).toThrow('Current chainId cannot be null or undefined.'); }); - it('should throw if current chain id is not convertable to integer', () => { + it('throws if current chain id is not convertable to integer', () => { const unexpectedChainId = 'unexpected chain id'; expect(() => util.validateTypedSignMessageDataV3V4( @@ -264,7 +264,7 @@ describe('utils', () => { ); }); - it('should throw if current chain id is not matched with provided in message data', () => { + it('throws if current chain id is not matched with provided in message data', () => { const chainId = toHex(2); expect(() => util.validateTypedSignMessageDataV3V4( @@ -287,7 +287,7 @@ describe('utils', () => { ); }); - it('should throw if data not in typed message schema', () => { + it('throws if data not in typed message schema', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -301,7 +301,7 @@ describe('utils', () => { ).toThrow('Data must conform to EIP-712 schema.'); }); - it('should not throw if data is correct', () => { + it('does not throw if data is correct', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -315,7 +315,7 @@ describe('utils', () => { ).not.toThrow(); }); - it('should not throw if data is correct (object format)', () => { + it('does not throw if data is correct (object format)', () => { expect(() => util.validateTypedSignMessageDataV3V4( { @@ -331,7 +331,7 @@ describe('utils', () => { }); describe('validateEncryptionPublicKeyMessageData', () => { - it('should throw if no from address', () => { + it('throws if no from address', () => { expect(() => // TODO: Replace `any` with type // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -339,7 +339,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: undefined must be a valid string.`); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '01'; expect(() => util.validateEncryptionPublicKeyMessageData({ @@ -350,7 +350,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if invalid type from address', () => { const from = 123; expect(() => util.validateEncryptionPublicKeyMessageData({ @@ -361,7 +361,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should not throw if from address is correct', () => { + it('does not throw if from address is correct', () => { expect(() => util.validateEncryptionPublicKeyMessageData({ from: '0x3244e191f1b4903970224322180f1fbbc415696b', @@ -373,7 +373,7 @@ describe('utils', () => { }); describe('validateDecryptedMessageData', () => { - it('should throw if no from address', () => { + it('throws if no from address', () => { // TODO: Replace `any` with type // eslint-disable-next-line @typescript-eslint/no-explicit-any expect(() => util.validateDecryptedMessageData({} as any)).toThrow( @@ -381,7 +381,7 @@ describe('utils', () => { ); }); - it('should throw if invalid from address', () => { + it('throws if invalid from address', () => { const from = '01'; expect(() => util.validateDecryptedMessageData({ @@ -392,7 +392,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should throw if invalid type from address', () => { + it('throws if invalid type from address', () => { const from = 123; expect(() => util.validateDecryptedMessageData({ @@ -403,7 +403,7 @@ describe('utils', () => { ).toThrow(`Invalid "from" address: ${from} must be a valid string.`); }); - it('should not throw if from address is correct', () => { + it('does not throw if from address is correct', () => { expect(() => util.validateDecryptedMessageData({ from: '0x3244e191f1b4903970224322180f1fbbc415696b',