Adds json file extension test case

This commit is contained in:
Akshay Nair
2020-10-11 23:56:32 +05:30
parent dda977068a
commit e142b024b5
4 changed files with 13 additions and 17 deletions
+7
View File
@@ -1,7 +1,14 @@
const R = require('ramda');
const fs = require('fs');
const { getDomains, validateDomainData } = require('../utils/domain');
const { DOMAINS_PATH } = require('../utils/constants');
describe('Domains', () => {
it('should all be json', async () => {
const files = await fs.promises.readdir(DOMAINS_PATH, {});
expect(files.filter(f => !/\.json$/g.test(f)).length).toBe(0);
});
it('should be valid', (done) => {
getDomains()
.then(R.map(data => {
+4 -1
View File
@@ -10,6 +10,8 @@ const { DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN, DOMAIN_API_HOST, DOMAIN_API_
const IS_TEST = ENV === 'test';
const DOMAINS_PATH = require('path').resolve('domains');
module.exports = {
ENV,
VALID_RECORD_TYPES: ['CNAME', 'A', 'ALIAS', 'URL'],
@@ -18,5 +20,6 @@ module.exports = {
DOMAIN_API_KEY: IS_TEST ? 'testkey' : DOMAIN_API_KEY,
DOMAIN_API_HOST: IS_TEST ? 'example.com' : DOMAIN_API_HOST,
DOMAIN_API_PORT: IS_TEST ? 6969 : DOMAIN_API_PORT,
TTL: 5*60, // TODO: Increase ttl
DOMAINS_PATH,
TTL: 5*60*60,
};
+1 -3
View File
@@ -1,9 +1,7 @@
const fs = require('fs');
const path = require('path');
const R = require('ramda');
const { VALID_RECORD_TYPES } = require('./constants');
const DOMAINS_PATH = path.resolve('domains');
const { VALID_RECORD_TYPES, DOMAINS_PATH } = require('./constants');
const log = m => x => console.log(m, x) || x;
+1 -13
View File
@@ -1,7 +1,7 @@
const R = require('ramda');
const fetch = require('node-fetch');
const qs = require('qs');
const { DOMAIN_API_HOST, DOMAIN_API_PORT, DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN, ...c } = require('../constants');
const { DOMAIN_API_HOST, DOMAIN_API_PORT, DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN } = require('../constants');
const CpanelClient = (options) => {
// TODO: Make defaultQuery functional
@@ -80,18 +80,6 @@ const cpanel = CpanelClient({
dependencies: { fetch },
});
//cpanel.fetchZoneRecords()
//cpanel.addRedirection({
//domain: 'hello.is-a.dev',
//redirect: 'https://googole.com',
//type: 'permanent',
//redirect_wildcard: 1,
//redirect_www: 0,
//})
//cpanel.fetchRedirections()
//.then(d => console.log(JSON.stringify(d, null, 2)))
//.catch(console.error);
module.exports = {
cpanel,
CpanelClient,