Files
binect-js/tests/client.test.ts
tegwick b9aebb42f1 Add Binect SDK implementation, Explorer, and test suite
SDK (@binect/js):
- BinectClient with domain sub-clients (documents, sendings, accounts,
  attachments, invoices)
- HTTP Basic Auth, native fetch only (no runtime dependencies)
- TypeScript types matching Binect API vocabulary
- Status predicates and polling helpers in helpers.ts
- Structured error handling (BinectApiError, BinectAuthError)

Explorer:
- Standalone browser-based API explorer (explorer/index.html)
- Interactive testing without code

Tests:
- Unit tests for client, types, errors, helpers, http
- E2E tests for upload/delete and send/cancel workflows

Also includes:
- Architecture Decision Records (ADRs)
- Example DIN 5008 letter PDFs for testing
- API specification research notes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:10:34 +01:00

60 lines
1.7 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { BinectClient } from '../src/client.js';
import { DocumentsClient } from '../src/clients/documents.js';
import { AttachmentsClient } from '../src/clients/attachments.js';
import { SendingsClient } from '../src/clients/sendings.js';
import { AccountsClient } from '../src/clients/accounts.js';
import { InvoicesClient } from '../src/clients/invoices.js';
describe('BinectClient', () => {
it('creates client with required config', () => {
const client = new BinectClient({
username: 'test@example.com',
password: 'password123',
});
expect(client).toBeInstanceOf(BinectClient);
});
it('creates client with custom baseUrl', () => {
const client = new BinectClient({
username: 'test@example.com',
password: 'password123',
baseUrl: 'https://custom.api.com/v1',
});
expect(client).toBeInstanceOf(BinectClient);
});
describe('sub-clients', () => {
let client: BinectClient;
beforeAll(() => {
client = new BinectClient({
username: 'test@example.com',
password: 'password123',
});
});
it('has documents client', () => {
expect(client.documents).toBeInstanceOf(DocumentsClient);
});
it('has attachments client', () => {
expect(client.attachments).toBeInstanceOf(AttachmentsClient);
});
it('has sendings client', () => {
expect(client.sendings).toBeInstanceOf(SendingsClient);
});
it('has accounts client', () => {
expect(client.accounts).toBeInstanceOf(AccountsClient);
});
it('has invoices client', () => {
expect(client.invoices).toBeInstanceOf(InvoicesClient);
});
});
});