Adds req test cases for redirection fetch

This commit is contained in:
Akshay Nair
2020-10-11 22:22:28 +05:30
parent 3cdad9b28d
commit bd3a5a5043
+55 -3
View File
@@ -30,7 +30,7 @@ describe('Cpanel client', () => {
dependencies: { fetch },
});
await cpanel.fetchZoneRecords();
await cpanel.zone.fetch();
});
it('should make the correct request with query', async () => {
@@ -53,7 +53,7 @@ describe('Cpanel client', () => {
dependencies: { fetch },
});
await cpanel.fetchZoneRecords({ domain: 'foobar.boeey' });
await cpanel.zone.fetch({ domain: 'foobar.boeey' });
});
});
@@ -78,7 +78,7 @@ describe('Cpanel client', () => {
dependencies: { fetch },
});
await cpanel.addZoneRecord({
await cpanel.zone.add({
name: 'googo',
type: 'boyee',
cname: 'beey',
@@ -87,5 +87,57 @@ describe('Cpanel client', () => {
});
});
});
describe('fetchredirections', () => {
it('should make the correct request', async () => {
const fetch = mockFetch((url, request) => {
expect(url).toBe('https://example.com:2000/execute/Mime/list_redirects?cpanel_jsonapi_user=boy&cpanel_jsonapi_module=Mime&cpanel_jsonapi_func=list_redirects&cpanel_jsonapi_apiversion=2');
expect(request).toEqual({
headers: {
Authorization: 'cpanel boy:boybyebye',
},
rejectUnauthorized: false,
});
});
const cpanel = CpanelClient({
host: 'example.com',
port: 2000,
username: 'boy',
apiKey: 'boybyebye',
domain: 'a.b',
dependencies: { fetch },
});
await cpanel.redirection.fetch();
});
});
describe('addredirection', () => {
it('should make the correct request', async () => {
const fetch = mockFetch((url, request) => {
expect(url).toBe('https://example.com:2000/execute/Mime/add_redirect?domain=googo&destination=https%3A%2F%2Foodf.com&cpanel_jsonapi_user=boy&cpanel_jsonapi_module=Mime&cpanel_jsonapi_func=add_redirect&cpanel_jsonapi_apiversion=2');
expect(request).toEqual({
headers: {
Authorization: 'cpanel boy:boybyebye',
},
rejectUnauthorized: false,
});
});
const cpanel = CpanelClient({
host: 'example.com',
port: 2000,
username: 'boy',
apiKey: 'boybyebye',
domain: 'a.b',
dependencies: { fetch },
});
await cpanel.redirection.add({
domain: 'googo',
destination: 'https://oodf.com'
});
});
});
});