@monkeyscanjump/cloudflare-dyndns
Version:
A robust TypeScript application that automatically updates Cloudflare DNS records when your public IP address changes. Perfect for maintaining consistent domain names for home servers, WireGuard VPN, self-hosted services, or any system with a dynamic IP a
36 lines • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const DynDnsApp_1 = require("../../app/DynDnsApp");
const CloudflareService_1 = require("../../services/CloudflareService");
const IpDetectionService_1 = require("../../services/IpDetectionService");
const IpFileManager_1 = require("../../utils/IpFileManager");
// Simple mocks
jest.mock('../../services/CloudflareService');
jest.mock('../../services/IpDetectionService');
jest.mock('../../utils/IpFileManager');
jest.mock('../../utils/Logger');
describe('DynDnsApp Integration', () => {
beforeEach(() => {
jest.clearAllMocks();
// Simple mock implementations
CloudflareService_1.CloudflareService.prototype.initialize.mockResolvedValue(true);
CloudflareService_1.CloudflareService.prototype.verifyCredentials.mockResolvedValue(true);
CloudflareService_1.CloudflareService.prototype.updateDnsRecord.mockResolvedValue(true);
IpDetectionService_1.IpDetectionService.prototype.detectIp.mockResolvedValue('1.2.3.4');
IpFileManager_1.IpFileManager.prototype.getLastIp.mockReturnValue(null);
IpFileManager_1.IpFileManager.prototype.saveIp.mockReturnValue(true);
});
test('should run once successfully when IP has changed', async () => {
const app = new DynDnsApp_1.DynDnsApp({
API_TOKEN: 'token',
DOMAIN: 'example.com',
SUBDOMAIN: 'test',
LOG_FILE: 'log.txt',
LAST_IP_FILE: 'ip.txt'
});
const result = await app.runOnce();
expect(result).toBe(true);
expect(CloudflareService_1.CloudflareService.prototype.updateDnsRecord).toHaveBeenCalledWith('1.2.3.4');
});
});
//# sourceMappingURL=DynDnsApp.test.js.map