|
1 | 1 | /** |
2 | 2 | * AttributedBody Extraction Tests |
3 | 3 | * |
4 | | - * Tests for the node-typedstream based attributedBody extraction |
| 4 | + * Tests for the @parseaple/typedstream based attributedBody extraction |
5 | 5 | */ |
6 | 6 |
|
7 | 7 | import { describe, expect, it } from 'bun:test' |
8 | | -import { NSAttributedString, Unarchiver } from 'node-typedstream' |
| 8 | +import { NSAttributedString, Unarchiver } from '@parseaple/typedstream' |
9 | 9 |
|
10 | 10 | /** |
11 | 11 | * Helper function that mirrors the extraction logic in database.ts |
@@ -36,7 +36,7 @@ function extractTextFromAttributedBody(attributedBody: unknown): string | null { |
36 | 36 | return item.string |
37 | 37 | } |
38 | 38 |
|
39 | | - if (item?.values && Array.isArray(item.values)) { |
| 39 | + if (item !== null && typeof item === 'object' && 'values' in item && Array.isArray(item.values)) { |
40 | 40 | for (const val of item.values) { |
41 | 41 | if (val instanceof NSAttributedString && val.string) { |
42 | 42 | return val.string |
@@ -88,12 +88,12 @@ describe('AttributedBody Extraction', () => { |
88 | 88 |
|
89 | 89 | describe('NSAttributedString Handling', () => { |
90 | 90 | it('should correctly identify NSAttributedString type', () => { |
91 | | - const instance = new NSAttributedString() |
| 91 | + const instance = new NSAttributedString('', []) |
92 | 92 | expect(instance).toBeInstanceOf(NSAttributedString) |
93 | 93 | }) |
94 | 94 |
|
95 | 95 | it('should access string property of NSAttributedString', () => { |
96 | | - const instance = new NSAttributedString() |
| 96 | + const instance = new NSAttributedString('', []) |
97 | 97 | // NSAttributedString.string is the property we need |
98 | 98 | expect('string' in instance).toBe(true) |
99 | 99 | }) |
|
0 commit comments