@@ -129,4 +129,79 @@ describe('holon store adapter', () => {
129129 expect ( fact ?. factSets ) . toEqual ( expect . arrayContaining ( [ 'http://ex/fsNotes' , 'http://ex/fsBS' ] ) )
130130 expect ( fact ?. factSets ) . toHaveLength ( 2 )
131131 } )
132+
133+ it ( 'strips the XBRL role tag from element and dimension labels' , async ( ) => {
134+ // A holon's prefLabel is the filing's standard label, which tags structural
135+ // concepts with their role — `[Abstract]`, `[Table]`, `[Line Items]`,
136+ // `[Roll Forward]`, `[Member]`. These are metadata, not display names.
137+ const doc = {
138+ '@graph' : [
139+ {
140+ '@id' : 'http://ex/hdr' ,
141+ '@type' : `${ RS } Element` ,
142+ [ `${ SKOS } prefLabel` ] : "Statement of Stockholders' Equity [Abstract]" ,
143+ } ,
144+ {
145+ '@id' : 'http://ex/tbl' ,
146+ '@type' : `${ RS } Element` ,
147+ [ `${ SKOS } prefLabel` ] : 'Statement [Table]' ,
148+ } ,
149+ {
150+ '@id' : 'http://ex/li' ,
151+ '@type' : `${ RS } Element` ,
152+ [ `${ SKOS } prefLabel` ] : 'Statement [Line Items]' ,
153+ } ,
154+ {
155+ '@id' : 'http://ex/rf' ,
156+ '@type' : `${ RS } Element` ,
157+ [ `${ SKOS } prefLabel` ] : 'Increase (Decrease) in Stockholders’ Equity [Roll Forward]' ,
158+ } ,
159+ {
160+ '@id' : 'http://ex/fd' ,
161+ '@type' : `${ RS } Fact` ,
162+ [ `${ RS } element` ] : { '@id' : 'http://ex/rf' } ,
163+ [ `${ RS } period` ] : { '@id' : 'http://ex/p' } ,
164+ [ `${ RS } numericValue` ] : 60 ,
165+ [ `${ RS } dimension` ] : { '@id' : 'http://ex/d1' } ,
166+ } ,
167+ {
168+ '@id' : 'http://ex/d1' ,
169+ '@type' : `${ RS } Dimension` ,
170+ [ `${ RS } axis` ] : { '@id' : 'http://ex/axis' } ,
171+ [ `${ RS } member` ] : { '@id' : 'http://ex/mem' } ,
172+ [ `${ RS } isExplicit` ] : true ,
173+ } ,
174+ {
175+ '@id' : 'http://ex/axis' ,
176+ '@type' : `${ RS } Element` ,
177+ [ `${ SKOS } prefLabel` ] : 'Equity Components [Axis]' ,
178+ } ,
179+ {
180+ '@id' : 'http://ex/mem' ,
181+ '@type' : `${ RS } Element` ,
182+ [ `${ SKOS } prefLabel` ] : 'Common Stock [Member]' ,
183+ } ,
184+ ] ,
185+ }
186+ const model = await parseJsonld ( doc )
187+ expect ( model . elements [ 'http://ex/hdr' ] ?. label ) . toBe ( "Statement of Stockholders' Equity" )
188+ expect ( model . elements [ 'http://ex/tbl' ] ?. label ) . toBe ( 'Statement' )
189+ expect ( model . elements [ 'http://ex/li' ] ?. label ) . toBe ( 'Statement' )
190+ expect ( model . elements [ 'http://ex/rf' ] ?. label ) . toBe (
191+ 'Increase (Decrease) in Stockholders’ Equity'
192+ )
193+ const dim = model . facts . find ( ( f ) => f . id === 'http://ex/fd' ) ?. dimensions ?. [ 0 ]
194+ expect ( dim ?. axisLabel ) . toBe ( 'Equity Components' )
195+ expect ( dim ?. memberLabel ) . toBe ( 'Common Stock' )
196+ } )
197+
198+ it ( 'keeps a label that is only a role tag rather than emptying it' , async ( ) => {
199+ const doc = {
200+ '@graph' : [
201+ { '@id' : 'http://ex/bare' , '@type' : `${ RS } Element` , [ `${ SKOS } prefLabel` ] : '[Abstract]' } ,
202+ ] ,
203+ }
204+ const model = await parseJsonld ( doc )
205+ expect ( model . elements [ 'http://ex/bare' ] ?. label ) . toBe ( '[Abstract]' )
206+ } )
132207} )
0 commit comments