update tests

This commit is contained in:
2025-10-10 16:55:15 +00:00
parent 4b2c828dd6
commit b289cb67cf
11 changed files with 242 additions and 256 deletions

View File

@@ -0,0 +1,41 @@
import { expect, tap } from '@push.rocks/tapbundle';
import * as qenv from '@push.rocks/qenv';
const testQenv = new qenv.Qenv('./', './.nogit/');
import * as ghost from '../ts/index.js';
let testGhostInstance: ghost.Ghost;
let createdWebhook: any;
tap.test('initialize Ghost instance', async () => {
testGhostInstance = new ghost.Ghost({
baseUrl: 'http://localhost:2368',
adminApiKey: await testQenv.getEnvVarOnDemand('ADMIN_APIKEY'),
contentApiKey: await testQenv.getEnvVarOnDemand('CONTENT_APIKEY'),
});
expect(testGhostInstance).toBeInstanceOf(ghost.Ghost);
});
tap.test('should create webhook', async () => {
const timestamp = Date.now();
createdWebhook = await testGhostInstance.createWebhook({
event: 'post.published',
target_url: `https://example.com/webhook/${timestamp}`,
name: `Test Webhook ${timestamp}`
});
expect(createdWebhook).toBeTruthy();
expect(createdWebhook.id).toBeTruthy();
});
tap.test('should update webhook', async () => {
const updatedWebhook = await testGhostInstance.updateWebhook(createdWebhook.id, {
target_url: 'https://example.com/webhook/updated'
});
expect(updatedWebhook).toBeTruthy();
});
tap.test('should delete webhook', async () => {
await testGhostInstance.deleteWebhook(createdWebhook.id);
});
export default tap.start();