mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-13 06:23:35 +00:00
Adds domains directory validation and prettified error messages
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"description": "Test website by akshay",
|
||||
"owner": {
|
||||
"username": "phenax",
|
||||
"email": "phenax5@gmail.com"
|
||||
},
|
||||
"forceHttps": true,
|
||||
"record": {
|
||||
"CNAME": ["duckduckgo.com"]
|
||||
}
|
||||
}
|
||||
+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