Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Test Descriptions to Active Tense #78

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
26 changes: 13 additions & 13 deletions packages/message-manager/src/AbstractMessageManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ 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: {},
unapprovedMessagesCount: 0,
});
});

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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand Down Expand Up @@ -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';
Expand All @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down
20 changes: 10 additions & 10 deletions packages/message-manager/src/PersonalMessageManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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(
Expand All @@ -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' },
Expand All @@ -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({
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions packages/message-manager/src/TypedMessageManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand Down
Loading