Skip to content

Commit

Permalink
Fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdakin-magic committed Oct 18, 2023
1 parent ed6c0f7 commit 2a91c21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ test('Generates JSON RPC request payload with `showUI: false` parameter', async
expect(requestPayload.params).toEqual([{ email: expectedEmail, showUI: false }]);
});

test('Generates JSON RPC request payload with `variation` parameter', async () => {
test('Generates JSON RPC request payload with `overrides` parameter', async () => {
const magic = createMagicSDK();
magic.auth.request = jest.fn();

await magic.auth.loginWithEmailOTP({ email: expectedEmail, variation: 'my custom template' });
await magic.auth.loginWithEmailOTP({ email: expectedEmail, overrides: { variation: 'my custom template' } });

const requestPayload = magic.auth.request.mock.calls[0][0];
expect(requestPayload.jsonrpc).toBe('2.0');
expect(requestPayload.method).toBe(MagicPayloadMethod.LoginWithEmailOTP);
expect(requestPayload.params).toEqual([{ email: expectedEmail, variation: 'my custom template' }]);
expect(requestPayload.params).toEqual([{ email: expectedEmail, overrides: { variation: 'my custom template' } }]);
});

test('If `testMode` is enabled, testing-specific RPC method is used', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ test('Generates JSON RPC request payload with `redirectURI` parameter', async ()
expect(requestPayload.params).toEqual([{ email: 'test', showUI: true, redirectURI: 'helloworld' }]);
});

test('Generates JSON RPC request payload with `variation` parameter', async () => {
test('Generates JSON RPC request payload with `overrides` parameter', async () => {
const magic = createMagicSDK();
magic.auth.request = jest.fn();

await magic.auth.loginWithMagicLink({ email: 'test', showUI: true, variation: 'my custom template' });
await magic.auth.loginWithMagicLink({ email: 'test', showUI: true, overrides: { variation: 'my custom template' } });

const requestPayload = magic.auth.request.mock.calls[0][0];
expect(requestPayload.jsonrpc).toBe('2.0');
expect(requestPayload.method).toBe(MagicPayloadMethod.LoginWithMagicLink);
expect(requestPayload.params).toEqual([{ email: 'test', showUI: true, variation: 'my custom template' }]);
expect(requestPayload.params).toEqual([
{ email: 'test', showUI: true, overrides: { variation: 'my custom template' } },
]);
});

test('If `testMode` is enabled, testing-specific RPC method is used', async () => {
Expand Down

0 comments on commit 2a91c21

Please sign in to comment.