0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00
logto/packages/connectors/connector-logto-email/src/index.test.ts

31 lines
917 B
TypeScript
Raw Normal View History

import nock from 'nock';
2023-04-01 22:16:56 +08:00
import { VerificationCodeType } from '@logto/connector-kit';
import { emailEndpoint } from './constant.js';
import { mockedAccessTokenResponse, mockedConfig } from './mock.js';
const { jest } = import.meta;
const getConfig = jest.fn().mockResolvedValue(mockedConfig);
const { default: createConnector } = await import('./index.js');
describe('sendMessage()', () => {
beforeAll(() => {
nock(mockedConfig.tokenEndpoint).post('').reply(200, JSON.stringify(mockedAccessTokenResponse));
});
it('should send message successfully', async () => {
nock(mockedConfig.endpoint).post(emailEndpoint).reply(200);
const connector = await createConnector({ getConfig });
await expect(
connector.sendMessage({
to: 'wangsijie94@gmail.com',
type: VerificationCodeType.SignIn,
payload: { code: '1234' },
})
).resolves.not.toThrow();
});
});