UNPKG

epo-ops-sdk

Version:

TypeScript SDK for the European Patent Office's Open Patent Services (OPS) API with OAuth support

72 lines 2.84 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const client_1 = require("../client"); const dotenv_1 = __importDefault(require("dotenv")); // Load environment variables dotenv_1.default.config(); describe('EpoOpsClient', () => { let client; beforeAll(async () => { if (!process.env.EPO_CLIENT_ID || !process.env.EPO_CLIENT_SECRET) { throw new Error('Missing required environment variables. Please check your .env file.'); } client = new client_1.EpoOpsClient({ clientId: process.env.EPO_CLIENT_ID, clientSecret: process.env.EPO_CLIENT_SECRET, }); await client.initialize(); }); describe('Authentication', () => { it('should initialize with valid credentials', async () => { // The client should be initialized without throwing an error expect(client).toBeDefined(); }); }); describe('Patent Search', () => { it('should search for patents', async () => { const results = await client.searchPatents('TI=(artificial intelligence)', { range: '1-10' }); expect(results).toBeDefined(); expect(results.status).toBe(200); expect(results.data.results).toBeDefined(); expect(Array.isArray(results.data.results)).toBe(true); }); }); describe('Bibliographic Data', () => { it('should get bibliographic data for a patent', async () => { const biblio = await client.getBibliographicData({ type: 'publication', format: 'docdb', number: 'EP1000000A1' }); expect(biblio).toBeDefined(); expect(biblio.title).toBeDefined(); expect(biblio.abstract).toBeDefined(); }); }); describe('Classification', () => { it('should search for classifications', async () => { const results = await client.searchClassification('G06F'); expect(results).toBeDefined(); expect(results.status).toBe(200); expect(results.data).toBeDefined(); }); }); describe('Error Handling', () => { it('should handle invalid patent numbers', async () => { await expect(client.getBibliographicData({ type: 'publication', format: 'docdb', number: 'INVALID123' })).rejects.toThrow(); }); it('should handle invalid search queries', async () => { await expect(client.searchPatents('')).rejects.toThrow(); }); }); }); //# sourceMappingURL=client.test.js.map