@@ -716,6 +716,61 @@ describe('ParameterPropertyHandlerRange', () => {
716
716
} ) ;
717
717
} ) ;
718
718
719
+ it ( 'should handle array type with json array' , ( ) => {
720
+ const value1 = objectLoader . createCompactedResource ( DF . literal (
721
+ '["a", "b", "c"]' ,
722
+ DF . namedNode ( IRIS_RDF . JSON ) ,
723
+ ) ) ;
724
+ expect ( handler . hasValueType (
725
+ value1 ,
726
+ objectLoader . createCompactedResource ( {
727
+ '@type' : 'ParameterRangeArray' ,
728
+ parameterRangeValue : { '@id' : 'ex:SomeType1' } ,
729
+ } ) ,
730
+ errorContext ,
731
+ genericsContext ,
732
+ ) ) . toBeUndefined ( ) ;
733
+ expect ( ( < any > value1 . term ) . valueRaw ) . toEqual ( [ 'a' , 'b' , 'c' ] ) ;
734
+ } ) ;
735
+
736
+ it ( 'should throw on array type with invalid json array' , ( ) => {
737
+ const value1 = objectLoader . createCompactedResource ( DF . literal (
738
+ '["a" "b", "c"]' ,
739
+ DF . namedNode ( IRIS_RDF . JSON ) ,
740
+ ) ) ;
741
+ expect ( handler . hasValueType (
742
+ value1 ,
743
+ objectLoader . createCompactedResource ( {
744
+ '@type' : 'ParameterRangeArray' ,
745
+ parameterRangeValue : { '@id' : 'ex:SomeType1' } ,
746
+ } ) ,
747
+ errorContext ,
748
+ genericsContext ,
749
+ ) ) . toEqual ( {
750
+ description : expect . stringContaining ( 'JSON parse exception' ) ,
751
+ context : expect . anything ( ) ,
752
+ } ) ;
753
+ } ) ;
754
+
755
+ it ( 'should not handle array type with json non-array' , ( ) => {
756
+ const value1 = objectLoader . createCompactedResource ( DF . literal (
757
+ '"a"' ,
758
+ DF . namedNode ( IRIS_RDF . JSON ) ,
759
+ ) ) ;
760
+ expect ( handler . hasValueType (
761
+ value1 ,
762
+ objectLoader . createCompactedResource ( {
763
+ '@type' : 'ParameterRangeArray' ,
764
+ parameterRangeValue : { '@id' : 'ex:SomeType1' } ,
765
+ } ) ,
766
+ errorContext ,
767
+ genericsContext ,
768
+ ) ) . toEqual ( {
769
+ description : `value is not an RDF list` ,
770
+ context : expect . anything ( ) ,
771
+ } ) ;
772
+ } ) ;
773
+
719
774
it ( 'should handle tuple type with single entry' , ( ) => {
720
775
expect ( handler . hasValueType (
721
776
objectLoader . createCompactedResource ( {
0 commit comments