mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-17 04:15:13 +00:00
Adds domains directory validation and prettified error messages
This commit is contained in:
1 parent
2bdbbe18cb
commit
e8203c73f5
2 files changed
+26
-9
No files matched your search
+15
-9
@@ -2,15 +2,21 @@ const R = require('ramda');
|
||||
const { getDomains, validateDomainData } = require('../utils/domain');
|
||||
|
||||
describe('Domains', () => {
|
||||
it('should be valid', async () => {
|
||||
const list = await getDomains();
|
||||
|
||||
list.forEach(data => {
|
||||
const { errors } = validateDomainData(data);
|
||||
if (errors.length) {
|
||||
console.log(errors);
|
||||
}
|
||||
});
|
||||
it('should be valid', (done) => {
|
||||
getDomains()
|
||||
.then(R.map(data => {
|
||||
const { errors } = validateDomainData(data);
|
||||
if (errors.length) {
|
||||
const message = errors
|
||||
.map(([key, { reason }]) => `[${data.name}.${key}]: ${reason}`)
|
||||
.join('\n');
|
||||
return `\nValidation errors in ${data.name}.json: \n${message}`;
|
||||
}
|
||||
return '';
|
||||
}))
|
||||
.then(R.filter(R.complement(R.isEmpty)))
|
||||
.then(messages => messages.length ? done(messages.join('\n')) : done())
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user