mirror of
https://github.com/logto-io/logto.git
synced 2025-01-13 21:30:30 -05:00
f8710e147d
* feat(connector-smtp): add smtp connector * feat(connector-smtp): fix UTs
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { GetConnectorConfig } from '@logto/connector-types';
|
|
|
|
import SmtpConnector from '.';
|
|
import { SmtpConfig } from './types';
|
|
|
|
const getConnectorConfig = jest.fn() as GetConnectorConfig<SmtpConfig>;
|
|
|
|
const smtpMethods = new SmtpConnector(getConnectorConfig);
|
|
|
|
describe('validateConfig()', () => {
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('should pass on valid config', async () => {
|
|
await expect(
|
|
smtpMethods.validateConfig({
|
|
host: 'smtp.testing.com',
|
|
port: 80,
|
|
password: 'password',
|
|
username: 'username',
|
|
fromEmail: 'test@smtp.testing.com',
|
|
templates: [
|
|
{
|
|
contentType: 'text/plain',
|
|
content: 'This is for testing purposes only.',
|
|
subject: 'Logto Test with SMTP',
|
|
usageType: 'Test',
|
|
},
|
|
{
|
|
contentType: 'text/plain',
|
|
content: 'This is for sign-in purposes only.',
|
|
subject: 'Logto Sign In with SMTP',
|
|
usageType: 'SignIn',
|
|
},
|
|
{
|
|
contentType: 'text/plain',
|
|
content: 'This is for register purposes only.',
|
|
subject: 'Logto Register with SMTP',
|
|
usageType: 'Register',
|
|
},
|
|
{
|
|
contentType: 'text/plain',
|
|
content: 'This is for forgot-password purposes only.',
|
|
subject: 'Logto Forgot Password with SMTP',
|
|
usageType: 'ForgotPassword',
|
|
},
|
|
],
|
|
})
|
|
).resolves.not.toThrow();
|
|
});
|
|
|
|
it('throws if config is invalid', async () => {
|
|
await expect(smtpMethods.validateConfig({})).rejects.toThrow();
|
|
});
|
|
});
|