-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v1.0.5' into main
- Loading branch information
Showing
11 changed files
with
101 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "cliam", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"engines": { | ||
"node": ">=14.16" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,43 +56,73 @@ describe('Request payload', () => { | |
['from', 'replyTo', 'to', 'cc', 'bcc'].forEach(property => { | ||
|
||
describe(`.${property}`, () => { | ||
|
||
if ( ['to', 'cc', 'bcc'].includes(property) ) { | ||
|
||
if ( property === 'to' ) { | ||
|
||
it(`error - ${property} is required`, (done) => { | ||
payload.meta[property] = undefined; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}" is required`); | ||
done(); | ||
}); | ||
|
||
} | ||
|
||
if (property === 'to') { | ||
it(`error - ${property} must be an array`, (done) => { | ||
payload.meta[property] = {}; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}" must be an array`); | ||
done(); | ||
}); | ||
|
||
it(`error - ${property}.name is required`, (done) => { | ||
payload.meta[property] = { name: null, email: '[email protected]' }; | ||
payload.meta[property] = [ { name: null, email: '[email protected]' } ]; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}.name" must be a string`); | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}[0].name" must be a string`); | ||
done(); | ||
}); | ||
|
||
} | ||
|
||
it(`error - ${property}.name should be less than or equal to 48 chars`, (done) => { | ||
payload.meta[property] = { name: chance.string({ length: 49 }), email: '[email protected]' }; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}.name" length must be less than or equal to 48 characters long`); | ||
done(); | ||
}); | ||
|
||
if (property === 'to') { | ||
it(`error - ${property}.name should be less than or equal to 48 chars`, (done) => { | ||
payload.meta[property] = [ { name: chance.string({ length: 49 }), email: '[email protected]' } ]; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}[0].name" length must be less than or equal to 48 characters long`); | ||
done(); | ||
}); | ||
|
||
it(`error - ${property}.email is required`, (done) => { | ||
payload.meta[property] = { name: 'Yoda', email : null }; | ||
payload.meta[property] = [ { name: 'Yoda', email : null } ]; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}[0].email" must be a string`); | ||
done(); | ||
}); | ||
|
||
it(`error - ${property}.email should be a valid email address`, (done) => { | ||
payload.meta[property] = [ { name: 'Yoda', email : 'Yoda' } ]; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}.email" must be a string`); | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}[0].email" must be a valid email`); | ||
done(); | ||
}); | ||
|
||
} else { | ||
|
||
it(`error - ${property}.name should be less than or equal to 48 chars`, (done) => { | ||
payload.meta[property] = { name: chance.string({ length: 49 }), email: '[email protected]' }; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}.name" length must be less than or equal to 48 characters long`); | ||
done(); | ||
}); | ||
|
||
it(`error - ${property}.email should be a valid email address`, (done) => { | ||
payload.meta[property] = { name: 'Yoda', email : 'Yoda' }; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}.email" must be a valid email`); | ||
done(); | ||
}); | ||
|
||
} | ||
|
||
it(`error - ${property}.email should be a valid email address`, (done) => { | ||
payload.meta[property] = { name: 'Yoda', email : 'Yoda' }; | ||
const error = mailSchema.validate(payload, { abortEarly: true, allowUnknown: false })?.error; | ||
expect(error.details[0].message).to.be.eqls(`"meta.${property}.email" must be a valid email`); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters