60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import { tap, expect } from '@push.rocks/tapbundle';
|
|
import * as qenv from '@push.rocks/qenv';
|
|
import { BookStackAccount } from '../ts/index.js';
|
|
|
|
const testQenv = new qenv.Qenv('./', '.nogit/');
|
|
|
|
let bookstackAccount: BookStackAccount;
|
|
|
|
tap.test('should create a BookStackAccount instance', async () => {
|
|
const baseUrl = await testQenv.getEnvVarOnDemand('BOOKSTACK_URL');
|
|
const tokenId = await testQenv.getEnvVarOnDemand('BOOKSTACK_TOKENID');
|
|
const tokenSecret = await testQenv.getEnvVarOnDemand('BOOKSTACK_TOKENSECRET');
|
|
bookstackAccount = new BookStackAccount(baseUrl, tokenId, tokenSecret);
|
|
expect(bookstackAccount).toBeInstanceOf(BookStackAccount);
|
|
});
|
|
|
|
tap.test('should test connection', async () => {
|
|
const result = await bookstackAccount.testConnection();
|
|
expect(result).toHaveProperty('ok');
|
|
console.log('Connection test:', result);
|
|
});
|
|
|
|
tap.test('should get system info', async () => {
|
|
const info = await bookstackAccount.getSystemInfo();
|
|
expect(info).toHaveProperty('version');
|
|
console.log('System info:', info);
|
|
});
|
|
|
|
tap.test('should list books', async () => {
|
|
const books = await bookstackAccount.getBooks();
|
|
expect(books).toBeArray();
|
|
console.log(`Found ${books.length} books`);
|
|
});
|
|
|
|
tap.test('should list shelves', async () => {
|
|
const shelves = await bookstackAccount.getShelves();
|
|
expect(shelves).toBeArray();
|
|
console.log(`Found ${shelves.length} shelves`);
|
|
});
|
|
|
|
tap.test('should list chapters', async () => {
|
|
const chapters = await bookstackAccount.getChapters();
|
|
expect(chapters).toBeArray();
|
|
console.log(`Found ${chapters.length} chapters`);
|
|
});
|
|
|
|
tap.test('should list pages', async () => {
|
|
const pages = await bookstackAccount.getPages();
|
|
expect(pages).toBeArray();
|
|
console.log(`Found ${pages.length} pages`);
|
|
});
|
|
|
|
tap.test('should search content', async () => {
|
|
const results = await bookstackAccount.search('test');
|
|
expect(results).toBeArray();
|
|
console.log(`Found ${results.length} search results`);
|
|
});
|
|
|
|
export default tap.start();
|