update
This commit is contained in:
@ -14,15 +14,15 @@ tap.test('EmailValidator - should validate email formats correctly', async (tool
|
||||
const validator = new EmailValidator();
|
||||
|
||||
// Test valid email formats
|
||||
expect(validator.isValidFormat('user@example.com')).toBeTrue();
|
||||
expect(validator.isValidFormat('firstname.lastname@example.com')).toBeTrue();
|
||||
expect(validator.isValidFormat('user+tag@example.com')).toBeTrue();
|
||||
expect(validator.isValidFormat('user@example.com')).toEqual(true);
|
||||
expect(validator.isValidFormat('firstname.lastname@example.com')).toEqual(true);
|
||||
expect(validator.isValidFormat('user+tag@example.com')).toEqual(true);
|
||||
|
||||
// Test invalid email formats
|
||||
expect(validator.isValidFormat('user@')).toBeFalse();
|
||||
expect(validator.isValidFormat('@example.com')).toBeFalse();
|
||||
expect(validator.isValidFormat('user@example')).toBeFalse();
|
||||
expect(validator.isValidFormat('user.example.com')).toBeFalse();
|
||||
expect(validator.isValidFormat('user@')).toEqual(false);
|
||||
expect(validator.isValidFormat('@example.com')).toEqual(false);
|
||||
expect(validator.isValidFormat('user@example')).toEqual(false);
|
||||
expect(validator.isValidFormat('user.example.com')).toEqual(false);
|
||||
});
|
||||
|
||||
tap.test('EmailValidator - should perform comprehensive validation', async (tools) => {
|
||||
@ -30,8 +30,8 @@ tap.test('EmailValidator - should perform comprehensive validation', async (tool
|
||||
|
||||
// Test basic validation (syntax-only)
|
||||
const basicResult = await validator.validate('user@example.com', { checkSyntaxOnly: true });
|
||||
expect(basicResult.isValid).toBeTrue();
|
||||
expect(basicResult.details.formatValid).toBeTrue();
|
||||
expect(basicResult.isValid).toEqual(true);
|
||||
expect(basicResult.details.formatValid).toEqual(true);
|
||||
|
||||
// We can't reliably test MX validation in all environments, but the function should run
|
||||
const mxResult = await validator.validate('user@example.com', { checkMx: true });
|
||||
@ -43,8 +43,8 @@ tap.test('EmailValidator - should detect invalid emails', async (tools) => {
|
||||
const validator = new EmailValidator();
|
||||
|
||||
const invalidResult = await validator.validate('invalid@@example.com', { checkSyntaxOnly: true });
|
||||
expect(invalidResult.isValid).toBeFalse();
|
||||
expect(invalidResult.details.formatValid).toBeFalse();
|
||||
expect(invalidResult.isValid).toEqual(false);
|
||||
expect(invalidResult.details.formatValid).toEqual(false);
|
||||
});
|
||||
|
||||
tap.test('TemplateManager - should register and retrieve templates', async (tools) => {
|
||||
@ -72,8 +72,8 @@ tap.test('TemplateManager - should register and retrieve templates', async (tool
|
||||
|
||||
// List templates
|
||||
const templates = templateManager.listTemplates();
|
||||
expect(templates.length > 0).toBeTrue();
|
||||
expect(templates.some(t => t.id === 'test-template')).toBeTrue();
|
||||
expect(templates.length > 0).toEqual(true);
|
||||
expect(templates.some(t => t.id === 'test-template')).toEqual(true);
|
||||
});
|
||||
|
||||
tap.test('TemplateManager - should create smartmail from template', async (tools) => {
|
||||
@ -101,7 +101,7 @@ tap.test('TemplateManager - should create smartmail from template', async (tools
|
||||
expect(smartmail).toBeTruthy();
|
||||
expect(smartmail.options.from).toEqual('welcome@example.com');
|
||||
expect(smartmail.getSubject()).toEqual('Welcome, John Doe!');
|
||||
expect(smartmail.getBody(true).indexOf('Hello, John Doe!') > -1).toBeTrue();
|
||||
expect(smartmail.getBody(true).indexOf('Hello, John Doe!') > -1).toEqual(true);
|
||||
});
|
||||
|
||||
tap.test('Email - should handle template variables', async (tools) => {
|
||||
@ -121,7 +121,7 @@ tap.test('Email - should handle template variables', async (tools) => {
|
||||
// Test variable substitution
|
||||
expect(email.getSubjectWithVariables()).toEqual('Hello John Doe!');
|
||||
expect(email.getTextWithVariables()).toEqual('Welcome, John Doe! Your order #12345 has been processed.');
|
||||
expect(email.getHtmlWithVariables().indexOf('<strong>John Doe</strong>') > -1).toBeTrue();
|
||||
expect(email.getHtmlWithVariables().indexOf('<strong>John Doe</strong>') > -1).toEqual(true);
|
||||
|
||||
// Test with additional variables
|
||||
const additionalVars = {
|
||||
@ -133,7 +133,7 @@ tap.test('Email - should handle template variables', async (tools) => {
|
||||
|
||||
// Add a new variable
|
||||
email.setVariable('trackingNumber', 'TRK123456');
|
||||
expect(email.getTextWithVariables().indexOf('12345') > -1).toBeTrue();
|
||||
expect(email.getTextWithVariables().indexOf('12345') > -1).toEqual(true);
|
||||
|
||||
// Update multiple variables at once
|
||||
email.setVariables({
|
||||
@ -141,7 +141,7 @@ tap.test('Email - should handle template variables', async (tools) => {
|
||||
status: 'delivered'
|
||||
});
|
||||
|
||||
expect(email.getTextWithVariables().indexOf('67890') > -1).toBeTrue();
|
||||
expect(email.getTextWithVariables().indexOf('67890') > -1).toEqual(true);
|
||||
});
|
||||
|
||||
tap.test('Email and Smartmail compatibility - should convert between formats', async (tools) => {
|
||||
@ -172,9 +172,9 @@ tap.test('Email and Smartmail compatibility - should convert between formats', a
|
||||
|
||||
// Verify first conversion (Smartmail to Email)
|
||||
expect(email.from).toEqual('smartmail@example.com');
|
||||
expect(email.to.indexOf('recipient@example.com') > -1).toBeTrue();
|
||||
expect(email.to.indexOf('recipient@example.com') > -1).toEqual(true);
|
||||
expect(email.subject).toEqual('Test Subject');
|
||||
expect(email.html?.indexOf('This is a test email') > -1).toBeTrue();
|
||||
expect(email.html?.indexOf('This is a test email') > -1).toEqual(true);
|
||||
expect(email.attachments.length).toEqual(1);
|
||||
|
||||
// Convert back to Smartmail
|
||||
@ -182,10 +182,10 @@ tap.test('Email and Smartmail compatibility - should convert between formats', a
|
||||
|
||||
// Verify second conversion (Email back to Smartmail) with simplified assertions
|
||||
expect(convertedSmartmail.options.from).toEqual('smartmail@example.com');
|
||||
expect(Array.isArray(convertedSmartmail.options.to)).toBeTrue();
|
||||
expect(Array.isArray(convertedSmartmail.options.to)).toEqual(true);
|
||||
expect(convertedSmartmail.options.to.length).toEqual(1);
|
||||
expect(convertedSmartmail.getSubject()).toEqual('Test Subject');
|
||||
expect(convertedSmartmail.getBody(true).indexOf('This is a test email') > -1).toBeTrue();
|
||||
expect(convertedSmartmail.getBody(true).indexOf('This is a test email') > -1).toEqual(true);
|
||||
expect(convertedSmartmail.attachments.length).toEqual(1);
|
||||
});
|
||||
|
||||
@ -202,10 +202,10 @@ tap.test('Email - should validate email addresses', async (tools) => {
|
||||
});
|
||||
} catch (error) {
|
||||
errorThrown = true;
|
||||
expect(error.message.indexOf('Invalid sender email address') > -1).toBeTrue();
|
||||
expect(error.message.indexOf('Invalid sender email address') > -1).toEqual(true);
|
||||
}
|
||||
|
||||
expect(errorThrown).toBeTrue();
|
||||
expect(errorThrown).toEqual(true);
|
||||
|
||||
// Attempt with invalid recipient
|
||||
errorThrown = false;
|
||||
@ -219,10 +219,10 @@ tap.test('Email - should validate email addresses', async (tools) => {
|
||||
});
|
||||
} catch (error) {
|
||||
errorThrown = true;
|
||||
expect(error.message.indexOf('Invalid recipient email address') > -1).toBeTrue();
|
||||
expect(error.message.indexOf('Invalid recipient email address') > -1).toEqual(true);
|
||||
}
|
||||
|
||||
expect(errorThrown).toBeTrue();
|
||||
expect(errorThrown).toEqual(true);
|
||||
|
||||
// Valid email should not throw
|
||||
let validEmail: Email;
|
||||
@ -237,7 +237,7 @@ tap.test('Email - should validate email addresses', async (tools) => {
|
||||
expect(validEmail).toBeTruthy();
|
||||
expect(validEmail.from).toEqual('sender@example.com');
|
||||
} catch (error) {
|
||||
expect(error === undefined).toBeTrue(); // This should not happen
|
||||
expect(error === undefined).toEqual(true); // This should not happen
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user