mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-10-17 16:13:17 +00:00
mx: adds automatic priority for mx record lists + publishing
This commit is contained in:
1 parent
8d4788c61b
commit
eb484fe163
5 files changed
+36
-25
No files matched your search
@@ -1,6 +1,6 @@
|
||||
const R = require('ramda');
|
||||
const { getDomainService, diffRecords } = require('../utils/domain-service');
|
||||
const {DOMAIN_DOMAIN} = require('../utils/constants');
|
||||
const { DOMAIN_DOMAIN } = require('../utils/constants');
|
||||
|
||||
const getCpanel = ({ zone, addZone, removeZone, redir, addRedir, removeRedir } = {}) => ({
|
||||
zone: {
|
||||
@@ -115,16 +115,18 @@ describe('Domain service', () => {
|
||||
const addRedir = jest.fn(async () => ({}));
|
||||
const removeRedir = jest.fn(async () => ({}));
|
||||
|
||||
const mockDS = ({ zones, redirections }) => getDomainService({ cpanel: getCpanel({
|
||||
zone: async () => zones,
|
||||
redir: async () => redirections,
|
||||
addZone,
|
||||
addRedir,
|
||||
removeZone,
|
||||
removeRedir,
|
||||
}) });
|
||||
const mockDS = ({ zones, redirections }) => getDomainService({
|
||||
cpanel: getCpanel({
|
||||
zone: async () => zones,
|
||||
redir: async () => redirections,
|
||||
addZone,
|
||||
addRedir,
|
||||
removeZone,
|
||||
removeRedir,
|
||||
})
|
||||
});
|
||||
|
||||
const getRecordCalls = recfn => recfn.mock.calls.map(R.head).map(R.pick(['name', 'type', 'address', 'redirect', 'domain', 'line']));
|
||||
const getRecordCalls = recfn => recfn.mock.calls.map(R.head).map(R.pick(['name', 'type', 'address', 'redirect', 'domain', 'line', 'priority']));
|
||||
|
||||
beforeEach(() => {
|
||||
addZone.mockClear();
|
||||
@@ -187,11 +189,13 @@ describe('Domain service', () => {
|
||||
{ name: 'a', type: 'CNAME', address: 'boo' },
|
||||
{ name: 'b', type: 'CNAME', address: 'goo' },
|
||||
{ name: 'c', type: 'A', address: '12.131321.213' },
|
||||
{ name: 'c', type: 'MX', address: 'foobar.com', priority: 2 },
|
||||
]);
|
||||
|
||||
expect(addZone).toBeCalledTimes(1);
|
||||
expect(addZone).toBeCalledTimes(2);
|
||||
expect(getRecordCalls(addZone)).toEqual([
|
||||
{ name: 'c', type: 'A', address: '12.131321.213' },
|
||||
{ name: 'c', type: 'MX', address: 'foobar.com', priority: 2 },
|
||||
]);
|
||||
expect(removeZone).toBeCalledTimes(0);
|
||||
});
|
||||
|
||||
+14
-8
@@ -22,6 +22,7 @@ describe('toHostList', () => {
|
||||
{ name: 'akshay', record: { CNAME: 'phenax.github.io' } },
|
||||
{ name: 'foobar', record: { CNAME: 'v.io' } },
|
||||
{ name: 'xx', record: { A: ['1.2.3.4', '5.6.3.2', '1.2.31.1'] } },
|
||||
{ name: 'xx', record: { CNAME: 'foobar.com', MX: ['as.com', 'f.com'] } },
|
||||
]);
|
||||
|
||||
expect(res).toEqual([
|
||||
@@ -30,6 +31,9 @@ describe('toHostList', () => {
|
||||
{ name: 'xx', type: 'A', address: '1.2.3.4', ttl: TTL },
|
||||
{ name: 'xx', type: 'A', address: '5.6.3.2', ttl: TTL },
|
||||
{ name: 'xx', type: 'A', address: '1.2.31.1', ttl: TTL },
|
||||
{ name: 'xx', type: 'CNAME', address: 'foobar.com', ttl: TTL },
|
||||
{ name: 'xx', type: 'MX', address: 'as.com', priority: 20, ttl: TTL },
|
||||
{ name: 'xx', type: 'MX', address: 'f.com', priority: 21, ttl: TTL },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -40,14 +44,16 @@ describe('registerDomains', () => {
|
||||
const addRedir = jest.fn(async () => ({}));
|
||||
const removeRedir = jest.fn(async () => ({}));
|
||||
|
||||
const mockDS = ({ zones, redirections }) => getDomainService({ cpanel: getCpanel({
|
||||
zone: async () => zones,
|
||||
redir: async () => redirections,
|
||||
addZone,
|
||||
addRedir,
|
||||
removeZone,
|
||||
removeRedir,
|
||||
}) });
|
||||
const mockDS = ({ zones, redirections }) => getDomainService({
|
||||
cpanel: getCpanel({
|
||||
zone: async () => zones,
|
||||
redir: async () => redirections,
|
||||
addZone,
|
||||
addRedir,
|
||||
removeZone,
|
||||
removeRedir,
|
||||
})
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
addZone.mockClear();
|
||||
|
||||
Reference in new issue
Block a user