@@ -3,6 +3,7 @@ import * as td from 'testdouble'
33import * as assert from 'uvu/assert'
44import type { FetchBreadcrumbsProps } from './breadcrumbs.js'
55import { FetchBreadcrumbs } from './breadcrumbs.js'
6+ import type { Breadcrumb } from './types.js'
67
78test . before ( ( ) => {
89 td . replace ( console , 'log' )
@@ -141,23 +142,23 @@ test('FetchBreadcrumbs returns correct data structure', async () => {
141142
142143 try {
143144 const result = await FetchBreadcrumbs ( props )
144-
145+
145146 // Always returns an array
146147 assert . ok ( Array . isArray ( result ) )
147-
148+
148149 // Each breadcrumb should have required structure
149150 for ( const breadcrumb of result ) {
150151 assert . ok ( typeof breadcrumb === 'object' )
151152 assert . ok ( 'id' in breadcrumb )
152153 assert . ok ( 'name' in breadcrumb )
153154 assert . ok ( typeof breadcrumb . id === 'string' )
154155 assert . ok ( typeof breadcrumb . name === 'string' )
155-
156+
156157 // Icon is optional but if present should have correct structure
157158 if ( 'icon' in breadcrumb && breadcrumb . icon ) {
158159 assert . ok ( 'type' in breadcrumb . icon )
159160 assert . ok ( [ 'emoji' , 'external' , 'file' ] . includes ( breadcrumb . icon . type ) )
160-
161+
161162 if ( breadcrumb . icon . type === 'emoji' ) {
162163 assert . ok ( 'emoji' in breadcrumb . icon )
163164 } else {
@@ -172,6 +173,46 @@ test('FetchBreadcrumbs returns correct data structure', async () => {
172173 }
173174} )
174175
176+ test ( 'Breadcrumb type allows entries without icon' , ( ) => {
177+ // Pages without icon should still produce valid breadcrumb entries
178+ const breadcrumb : Breadcrumb = {
179+ id : 'page-without-icon' ,
180+ name : 'No Icon Page' ,
181+ }
182+
183+ assert . ok ( typeof breadcrumb . id === 'string' )
184+ assert . ok ( typeof breadcrumb . name === 'string' )
185+ assert . equal ( breadcrumb . icon , undefined )
186+ } )
187+
188+ test ( 'Breadcrumb type allows entries with emoji icon' , ( ) => {
189+ const breadcrumb : Breadcrumb = {
190+ id : 'page-with-emoji' ,
191+ name : 'Emoji Page' ,
192+ icon : {
193+ type : 'emoji' ,
194+ emoji : '📚' ,
195+ } ,
196+ }
197+
198+ assert . equal ( breadcrumb . icon ?. type , 'emoji' )
199+ } )
200+
201+ test ( 'Breadcrumb type allows entries with external icon' , ( ) => {
202+ const breadcrumb : Breadcrumb = {
203+ id : 'page-with-icon' ,
204+ name : 'Icon Page' ,
205+ icon : {
206+ type : 'external' ,
207+ src : '/images/page-icon-123.svg' ,
208+ url : 'https://www.notion.so/icons/bookmark-outline_blue.svg' ,
209+ } ,
210+ }
211+
212+ assert . equal ( breadcrumb . icon ?. type , 'external' )
213+ assert . ok ( breadcrumb . icon ?. src ?. includes ( '/images/' ) )
214+ } )
215+
175216test ( 'FetchBreadcrumbs supports all parent types correctly' , async ( ) => {
176217 const testCases : Array < {
177218 type : FetchBreadcrumbsProps [ 'type' ] ,
0 commit comments