mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-05-25 07:39:44 +00:00
Adds req test cases for redirection fetch
This commit is contained in:
+55
-3
@@ -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'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user