Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions __tests__/12-attributed-body.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* AttributedBody Extraction Tests
*
* Tests for the node-typedstream based attributedBody extraction
* Tests for the @parseaple/typedstream based attributedBody extraction
*/

import { describe, expect, it } from 'bun:test'
import { NSAttributedString, Unarchiver } from 'node-typedstream'
import { NSAttributedString, Unarchiver } from '@parseaple/typedstream'

/**
* Helper function that mirrors the extraction logic in database.ts
Expand Down Expand Up @@ -36,7 +36,7 @@ function extractTextFromAttributedBody(attributedBody: unknown): string | null {
return item.string
}

if (item?.values && Array.isArray(item.values)) {
if (item !== null && typeof item === 'object' && 'values' in item && Array.isArray(item.values)) {
for (const val of item.values) {
if (val instanceof NSAttributedString && val.string) {
return val.string
Expand Down Expand Up @@ -88,12 +88,12 @@ describe('AttributedBody Extraction', () => {

describe('NSAttributedString Handling', () => {
it('should correctly identify NSAttributedString type', () => {
const instance = new NSAttributedString()
const instance = new NSAttributedString('', [])
expect(instance).toBeInstanceOf(NSAttributedString)
})

it('should access string property of NSAttributedString', () => {
const instance = new NSAttributedString()
const instance = new NSAttributedString('', [])
// NSAttributedString.string is the property we need
expect('string' in instance).toBe(true)
})
Expand Down
Loading
Loading