@@ -501,4 +501,48 @@ describe('RdfObjectLoader', () => {
501501 } ) ;
502502 } ) ;
503503 } ) ;
504+
505+ describe ( 'an instance with unique literals' , ( ) : void => {
506+ let loader : RdfObjectLoader ;
507+
508+ beforeEach ( ( ) : void => {
509+ loader = new RdfObjectLoader ( { uniqueLiterals : true } ) ;
510+ } ) ;
511+
512+ it ( 'does not store literals in the resource cache.' , async ( ) : Promise < void > => {
513+ await loader . import ( streamifyArray ( [
514+ quad ( 'http://example.org/s' , 'http://example.org/p' , '"test"' ) ,
515+ ] ) ) ;
516+ const resourceP = loader . getOrMakeResource ( DF . namedNode ( 'http://example.org/p' ) ) ;
517+ const resourceS = loader . getOrMakeResource ( DF . namedNode ( 'http://example.org/s' ) ) ;
518+ expect ( loader . resources ) . toEqual ( {
519+ 'http://example.org/p' : resourceP ,
520+ 'http://example.org/s' : resourceS ,
521+ } ) ;
522+ expect ( loader . resources [ '"test"' ] ) . toBeUndefined ( ) ;
523+ } ) ;
524+
525+ it ( 'should normalize a list' , async ( ) => {
526+ await loader . import ( streamifyArray ( [
527+ quad ( 'http://example.org/listResource' , 'http://example.org/listPredicate' , 'http://example.org/l0' ) ,
528+ quad ( 'http://example.org/l0' , 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first' , '"A"' ) ,
529+ quad ( 'http://example.org/l0' , 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest' , 'http://example.org/l1' ) ,
530+ quad ( 'http://example.org/l1' , 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first' , '"B"' ) ,
531+ quad ( 'http://example.org/l1' , 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest' , 'http://example.org/l2' ) ,
532+ quad ( 'http://example.org/l2' , 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first' , '"C"' ) ,
533+ quad ( 'http://example.org/l2' ,
534+ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest' ,
535+ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil' ) ,
536+ ] ) ) ;
537+ const valueA = loader . getOrMakeResource ( DF . literal ( 'A' ) ) ;
538+ const valueB = loader . getOrMakeResource ( DF . literal ( 'B' ) ) ;
539+ const valueC = loader . getOrMakeResource ( DF . literal ( 'C' ) ) ;
540+ const list = loader . resources [ 'http://example.org/listResource' ]
541+ . propertiesUri [ 'http://example.org/listPredicate' ] [ 0 ] . list ;
542+ expect ( list ?. [ 0 ] ) . not . toBe ( valueA ) ;
543+ expect ( list ?. [ 0 ] . value ) . toEqual ( valueA . value ) ;
544+ expect ( list ?. [ 1 ] . value ) . toEqual ( valueB . value ) ;
545+ expect ( list ?. [ 2 ] . value ) . toEqual ( valueC . value ) ;
546+ } ) ;
547+ } ) ;
504548} ) ;
0 commit comments