diff --git a/domains/test.json b/domains/test.json new file mode 100644 index 000000000..1f8fd91e1 --- /dev/null +++ b/domains/test.json @@ -0,0 +1,11 @@ +{ + "description": "Test website by akshay", + "owner": { + "username": "phenax", + "email": "phenax5@gmail.com" + }, + "forceHttps": true, + "record": { + "CNAME": ["duckduckgo.com"] + } +} diff --git a/tests/domains.test.js b/tests/domains.test.js index 28d73d895..37c59575e 100644 --- a/tests/domains.test.js +++ b/tests/domains.test.js @@ -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); }); });