Rebuild company overview analysis page
This commit is contained in:
41
lib/server/sec-description.test.ts
Normal file
41
lib/server/sec-description.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { __secDescriptionInternals, extractBusinessDescription } from './sec-description';
|
||||
|
||||
describe('sec description extraction', () => {
|
||||
it('extracts Item 1 Business content from normalized filing text', () => {
|
||||
const text = `
|
||||
PART I
|
||||
|
||||
ITEM 1. BUSINESS
|
||||
|
||||
Microsoft develops and supports software, services, devices, and solutions worldwide. The company operates through productivity, cloud, and personal computing franchises. Its strategy centers on platform breadth, recurring commercial relationships, and enterprise adoption.
|
||||
|
||||
ITEM 1A. RISK FACTORS
|
||||
|
||||
Competition remains intense.
|
||||
`.trim();
|
||||
|
||||
const description = extractBusinessDescription(text);
|
||||
|
||||
expect(description).toContain('Microsoft develops and supports software');
|
||||
expect(description).not.toContain('RISK FACTORS');
|
||||
});
|
||||
|
||||
it('falls back to the first meaningful paragraph when Item 1 is missing', () => {
|
||||
const text = `
|
||||
Forward-looking statements
|
||||
|
||||
This company designs semiconductors for accelerated computing workloads and sells related systems, networking products, and software. It serves hyperscale, enterprise, and sovereign demand across several end markets.
|
||||
|
||||
Additional introductory text.
|
||||
`.trim();
|
||||
|
||||
expect(extractBusinessDescription(text)).toContain('designs semiconductors');
|
||||
});
|
||||
|
||||
it('clips long extracted text on sentence boundaries', () => {
|
||||
const clipped = __secDescriptionInternals.clipAtSentenceBoundary(`${'A short sentence. '.repeat(80)}`, 200);
|
||||
expect(clipped.length).toBeLessThanOrEqual(200);
|
||||
expect(clipped.endsWith('.')).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user