smartmail/test/test.ts

42 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

2018-09-29 21:57:25 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2022-08-07 09:38:07 +00:00
import * as smartmail from '../ts/index.js';
2018-09-29 21:57:25 +00:00
2020-06-18 15:34:05 +00:00
let emailAddressValidatorInstance: smartmail.EmailAddressValidator;
tap.test('should create an instance of EmailAddressValidator', async () => {
emailAddressValidatorInstance = new smartmail.EmailAddressValidator();
2022-08-07 09:38:07 +00:00
expect(emailAddressValidatorInstance).toBeInstanceOf(smartmail.EmailAddressValidator);
2020-06-18 15:34:05 +00:00
});
tap.test('should validate an email', async () => {
const result = await emailAddressValidatorInstance.validate('sandbox@bleu.de');
2022-08-07 09:38:07 +00:00
expect(result.freemail).toBeFalse();
expect(result.disposable).toBeFalse();
2020-06-18 21:04:52 +00:00
console.log(result);
});
tap.test('should recognize an email as freemail', async () => {
const result = await emailAddressValidatorInstance.validate('sandbox@gmail.com');
2022-08-07 09:38:07 +00:00
expect(result.freemail).toBeTrue();
expect(result.disposable).toBeFalse();
2020-06-18 21:04:52 +00:00
console.log(result);
});
tap.test('should recognize an email as disposable', async () => {
const result = await emailAddressValidatorInstance.validate('sandbox@gmx.de');
2022-08-07 09:38:07 +00:00
expect(result.freemail).toBeFalse();
expect(result.disposable).toBeTrue();
2020-06-18 21:04:52 +00:00
console.log(result);
2020-06-18 15:34:05 +00:00
});
2020-06-18 16:21:06 +00:00
tap.test('should create a SmartMail', async () => {
2019-10-26 21:45:35 +00:00
const testSmartmail = new smartmail.Smartmail({
body: 'hi there',
from: 'noreply@mail.lossless.com',
2022-08-07 09:38:07 +00:00
subject: 'hi from here',
2019-10-26 21:45:35 +00:00
});
2022-08-07 09:38:07 +00:00
expect(testSmartmail).toBeInstanceOf(smartmail.Smartmail);
2018-09-29 21:57:25 +00:00
});
tap.start();