@@ -11,9 +11,126 @@ const {expect} = chai;
1111
1212describe ( 'query.dcql' , ( ) => {
1313 describe ( 'QueryByExample => DCQL' , ( ) => {
14- it ( 'should pass' , async ( ) => {
15- const result = _fromQueryByExampleQuery ( { } ) ;
16- expect ( result ) . to . exist ;
14+ it ( 'should process deep query' , async ( ) => {
15+ const dcqlCredentialQuery = _fromQueryByExampleQuery ( {
16+ credentialQuery : {
17+ reason : `Please present your child's birth certificate to complete ` +
18+ 'the verification process.' ,
19+ example : {
20+ '@context' : [
21+ 'https://www.w3.org/ns/credentials/v2' ,
22+ 'https://w3id.org/vital-records/v1rc4'
23+ ] ,
24+ type : [
25+ 'BirthCertificateCredential'
26+ ] ,
27+ credentialSubject : {
28+ type : 'BirthCertificate' ,
29+ certifier : { } ,
30+ newborn : {
31+ name : '' ,
32+ birthDate : '' ,
33+ parent : [ {
34+ name : 'John Doe'
35+ } ]
36+ }
37+ }
38+ }
39+ }
40+ } ) ;
41+ expect ( dcqlCredentialQuery . id ) . to . exist ;
42+ expect ( dcqlCredentialQuery . format ) . to . eql ( 'ldp_vc' ) ;
43+ expect ( dcqlCredentialQuery . meta . type_values ) . to . deep . equal ( [
44+ 'https://www.w3.org/2018/credentials#VerifiableCredential'
45+ ] ) ;
46+ expect ( dcqlCredentialQuery . claims ) . to . deep . equal ( [
47+ {
48+ path : [ '@context' , 0 ] ,
49+ values : [ 'https://www.w3.org/ns/credentials/v2' ]
50+ } ,
51+ {
52+ path : [ '@context' , 1 ] ,
53+ values : [ 'https://w3id.org/vital-records/v1rc4' ]
54+ } ,
55+ {
56+ path : [ 'type' ] ,
57+ values : [ 'BirthCertificateCredential' ] } ,
58+ {
59+ path : [ 'credentialSubject' , 'type' ] ,
60+ values : [ 'BirthCertificate' ]
61+ } ,
62+ {
63+ path : [ 'credentialSubject' , 'certifier' ] } ,
64+ {
65+ path : [ 'credentialSubject' , 'newborn' , 'name' ] } ,
66+ {
67+ path : [ 'credentialSubject' , 'newborn' , 'birthDate' ] } ,
68+ {
69+ path : [ 'credentialSubject' , 'newborn' , 'parent' , 0 , 'name' ] ,
70+ values : [ 'John Doe' ]
71+ }
72+ ] ) ;
73+ } ) ;
74+ it ( 'should process deep query and nullyify indices' , async ( ) => {
75+ const dcqlCredentialQuery = _fromQueryByExampleQuery ( {
76+ nullyifyArrayIndices : true ,
77+ credentialQuery : {
78+ reason : `Please present your child's birth certificate to complete ` +
79+ 'the verification process.' ,
80+ example : {
81+ '@context' : [
82+ 'https://www.w3.org/ns/credentials/v2' ,
83+ 'https://w3id.org/vital-records/v1rc4'
84+ ] ,
85+ type : [
86+ 'BirthCertificateCredential'
87+ ] ,
88+ credentialSubject : {
89+ type : 'BirthCertificate' ,
90+ certifier : { } ,
91+ newborn : {
92+ name : '' ,
93+ birthDate : '' ,
94+ parent : [ {
95+ name : 'John Doe'
96+ } ]
97+ }
98+ }
99+ }
100+ }
101+ } ) ;
102+ expect ( dcqlCredentialQuery . id ) . to . exist ;
103+ expect ( dcqlCredentialQuery . format ) . to . eql ( 'ldp_vc' ) ;
104+ expect ( dcqlCredentialQuery . meta . type_values ) . to . deep . equal ( [
105+ 'https://www.w3.org/2018/credentials#VerifiableCredential'
106+ ] ) ;
107+ expect ( dcqlCredentialQuery . claims ) . to . deep . equal ( [
108+ {
109+ path : [ '@context' , 0 ] ,
110+ values : [ 'https://www.w3.org/ns/credentials/v2' ]
111+ } ,
112+ {
113+ path : [ '@context' , 1 ] ,
114+ values : [ 'https://w3id.org/vital-records/v1rc4' ]
115+ } ,
116+ {
117+ path : [ 'type' ] ,
118+ values : [ 'BirthCertificateCredential' ] } ,
119+ {
120+ path : [ 'credentialSubject' , 'type' ] ,
121+ values : [ 'BirthCertificate' ]
122+ } ,
123+ {
124+ path : [ 'credentialSubject' , 'certifier' ] } ,
125+ {
126+ path : [ 'credentialSubject' , 'newborn' , 'name' ] } ,
127+ {
128+ path : [ 'credentialSubject' , 'newborn' , 'birthDate' ] } ,
129+ {
130+ path : [ 'credentialSubject' , 'newborn' , 'parent' , null , 'name' ] ,
131+ values : [ 'John Doe' ]
132+ }
133+ ] ) ;
17134 } ) ;
18135 } ) ;
19136} ) ;
0 commit comments