@@ -614,6 +614,36 @@ describe('expansionMap', () => {
614614 assert . equal ( expansionMapCalled , true ) ;
615615 } ) ;
616616
617+ it ( 'should be called on relative iri for type term in scoped context' , async ( ) => {
618+ const docWithRelativeIriId = {
619+ '@context' : {
620+ 'definedType' : {
621+ '@id' : 'https://example.com#definedType' ,
622+ '@context' : {
623+ 'definedTerm' : 'https://example.com#definedTerm'
624+
625+ }
626+ }
627+ } ,
628+ 'id' : "urn:absoluteiri" ,
629+ '@type' : "definedType" ,
630+ definedTerm : {
631+ '@type' : 'relativeiri'
632+ }
633+ } ;
634+
635+ let expansionMapCalled = false ;
636+ const expansionMap = info => {
637+ if ( info . relativeIri === 'relativeiri' ) {
638+ expansionMapCalled = true ;
639+ }
640+ } ;
641+
642+ await jsonld . expand ( docWithRelativeIriId , { expansionMap} ) ;
643+
644+ assert . equal ( expansionMapCalled , true ) ;
645+ } ) ;
646+
617647 it ( 'should be called on relative iri for \
618648 type term with multiple relative iri types' , async ( ) => {
619649 const docWithRelativeIriId = {
@@ -638,6 +668,38 @@ describe('expansionMap', () => {
638668 assert . equal ( expansionMapCalledTimes , 3 ) ;
639669 } ) ;
640670
671+ it ( 'should be called on relative iri for \
672+ type term with multiple relative iri types in scoped context' , async ( ) => {
673+ const docWithRelativeIriId = {
674+ '@context' : {
675+ 'definedType' : {
676+ '@id' : 'https://example.com#definedType' ,
677+ '@context' : {
678+ 'definedTerm' : 'https://example.com#definedTerm'
679+
680+ }
681+ }
682+ } ,
683+ 'id' : "urn:absoluteiri" ,
684+ '@type' : "definedType" ,
685+ definedTerm : {
686+ '@type' : [ "relativeiri" , "anotherRelativeiri" ]
687+ }
688+ } ;
689+
690+ let expansionMapCalledTimes = 0 ;
691+ const expansionMap = info => {
692+ if ( info . relativeIri === 'relativeiri' ||
693+ info . relativeIri === 'anotherRelativeiri' ) {
694+ expansionMapCalledTimes ++ ;
695+ }
696+ } ;
697+
698+ await jsonld . expand ( docWithRelativeIriId , { expansionMap} ) ;
699+
700+ assert . equal ( expansionMapCalledTimes , 3 ) ;
701+ } ) ;
702+
641703 it ( 'should be called on relative iri for \
642704 type term with multiple types' , async ( ) => {
643705 const docWithRelativeIriId = {
@@ -764,6 +826,7 @@ describe('expansionMap', () => {
764826 type : '@vocab' ,
765827 vocab : 'http://example.com/' ,
766828 value : 'term' ,
829+ typeExpansion : false ,
767830 result : 'http://example.com/term'
768831 } ) ;
769832 expansionMapCalled = true ;
@@ -789,6 +852,7 @@ describe('expansionMap', () => {
789852 type : '@vocab' ,
790853 vocab : 'http://example.com/' ,
791854 value : 'relativeIri' ,
855+ typeExpansion : true ,
792856 result : 'http://example.com/relativeIri'
793857 } ) ;
794858 expansionMapCalled = true ;
@@ -815,6 +879,7 @@ describe('expansionMap', () => {
815879 type : '@vocab' ,
816880 vocab : 'http://example.com/' ,
817881 value : 'relativeIri' ,
882+ typeExpansion : true ,
818883 result : 'http://example.com/relativeIri'
819884 } ) ;
820885 expansionMapCalled = true ;
@@ -841,6 +906,7 @@ describe('expansionMap', () => {
841906 type : '@base' ,
842907 base : 'http://example.com/' ,
843908 value : 'relativeIri' ,
909+ typeExpansion : false ,
844910 result : 'http://example.com/relativeIri'
845911 } ) ;
846912 expansionMapCalled = true ;
@@ -869,6 +935,7 @@ describe('expansionMap', () => {
869935 type : '@base' ,
870936 base : 'http://example.com/' ,
871937 value : 'relativeIri' ,
938+ typeExpansion : false ,
872939 result : 'http://example.com/relativeIri'
873940 } ) ;
874941 expansionMapCalled = true ;
@@ -896,6 +963,7 @@ describe('expansionMap', () => {
896963 type : '@base' ,
897964 base : 'http://example.com/' ,
898965 value : 'relativeIri' ,
966+ typeExpansion : true ,
899967 result : 'http://example.com/relativeIri'
900968 } ) ;
901969 expansionMapCalled = true ;
@@ -924,6 +992,7 @@ describe('expansionMap', () => {
924992 type : '@base' ,
925993 base : 'http://example.com/' ,
926994 value : 'relativeIri' ,
995+ typeExpansion : true ,
927996 result : 'http://example.com/relativeIri'
928997 } ) ;
929998 expansionMapCalled = true ;
0 commit comments