1616import { Metadata } from "../../src/display/metadata.js" ;
1717import { MetadataParser } from "../../src/core/metadata_parser.js" ;
1818
19- const emptyObj = Object . create ( null ) ;
20-
2119function createMetadata ( data ) {
2220 const metadataParser = new MetadataParser ( data ) ;
2321 return new Metadata ( metadataParser . serializable ) ;
@@ -33,13 +31,10 @@ describe("metadata", function () {
3331 "</rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta>" ;
3432 const metadata = createMetadata ( data ) ;
3533
36- expect ( metadata . has ( "dc:title" ) ) . toBeTruthy ( ) ;
37- expect ( metadata . has ( "dc:qux" ) ) . toBeFalsy ( ) ;
38-
3934 expect ( metadata . get ( "dc:title" ) ) . toEqual ( "Foo bar baz" ) ;
4035 expect ( metadata . get ( "dc:qux" ) ) . toEqual ( null ) ;
4136
42- expect ( metadata . getAll ( ) ) . toEqual ( { "dc:title" : "Foo bar baz" } ) ;
37+ expect ( [ ... metadata ] ) . toEqual ( [ [ "dc:title" , "Foo bar baz" ] ] ) ;
4338 } ) ;
4439
4540 it ( "should repair and handle invalid metadata" , function ( ) {
@@ -51,13 +46,10 @@ describe("metadata", function () {
5146 "</rdf:Description></rdf:RDF></x:xmpmeta>" ;
5247 const metadata = createMetadata ( data ) ;
5348
54- expect ( metadata . has ( "dc:title" ) ) . toBeTruthy ( ) ;
55- expect ( metadata . has ( "dc:qux" ) ) . toBeFalsy ( ) ;
56-
5749 expect ( metadata . get ( "dc:title" ) ) . toEqual ( "PDF&" ) ;
5850 expect ( metadata . get ( "dc:qux" ) ) . toEqual ( null ) ;
5951
60- expect ( metadata . getAll ( ) ) . toEqual ( { "dc:title" : "PDF&" } ) ;
52+ expect ( [ ... metadata ] ) . toEqual ( [ [ "dc:title" , "PDF&" ] ] ) ;
6153 } ) ;
6254
6355 it ( "should repair and handle invalid metadata (bug 1424938)" , function ( ) {
@@ -94,19 +86,16 @@ describe("metadata", function () {
9486 "</x:xmpmeta>" ;
9587 const metadata = createMetadata ( data ) ;
9688
97- expect ( metadata . has ( "dc:title" ) ) . toBeTruthy ( ) ;
98- expect ( metadata . has ( "dc:qux" ) ) . toBeFalsy ( ) ;
99-
10089 expect ( metadata . get ( "dc:title" ) ) . toEqual (
10190 "L'Odissee thématique logo Odisséé - décembre 2008.pub"
10291 ) ;
10392 expect ( metadata . get ( "dc:qux" ) ) . toEqual ( null ) ;
10493
105- expect ( metadata . getAll ( ) ) . toEqual ( {
106- "dc:creator" : [ "ODIS" ] ,
107- "dc:title" : "L'Odissee thématique logo Odisséé - décembre 2008.pub" ,
108- "xap:creatortool" : "PDFCreator Version 0.9.6" ,
109- } ) ;
94+ expect ( [ ... metadata ] . sort ( ) ) . toEqual ( [
95+ [ "dc:creator" , [ "ODIS" ] ] ,
96+ [ "dc:title" , "L'Odissee thématique logo Odisséé - décembre 2008.pub" ] ,
97+ [ "xap:creatortool" , "PDFCreator Version 0.9.6" ] ,
98+ ] ) ;
11099 } ) ;
111100
112101 it ( "should gracefully handle incomplete tags (issue 8884)" , function ( ) {
@@ -137,7 +126,7 @@ describe("metadata", function () {
137126 '<?xpacket end="w"?>' ;
138127 const metadata = createMetadata ( data ) ;
139128
140- expect ( metadata . getAll ( ) ) . toEqual ( emptyObj ) ;
129+ expect ( [ ... metadata ] ) . toEqual ( [ ] ) ;
141130 } ) ;
142131
143132 it ( 'should gracefully handle "junk" before the actual metadata (issue 10395)' , function ( ) {
@@ -168,26 +157,23 @@ describe("metadata", function () {
168157 '</rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="w"?>' ;
169158 const metadata = createMetadata ( data ) ;
170159
171- expect ( metadata . has ( "dc:title" ) ) . toBeTruthy ( ) ;
172- expect ( metadata . has ( "dc:qux" ) ) . toBeFalsy ( ) ;
173-
174160 expect ( metadata . get ( "dc:title" ) ) . toEqual ( "" ) ;
175161 expect ( metadata . get ( "dc:qux" ) ) . toEqual ( null ) ;
176162
177- expect ( metadata . getAll ( ) ) . toEqual ( {
178- "dc:creator" : [ "" ] ,
179- "dc:description" : "" ,
180- "dc:format" : "application/pdf" ,
181- "dc:subject" : [ ] ,
182- "dc:title" : "" ,
183- "pdf:keywords" : "" ,
184- "pdf:pdfversion" : "1.7" ,
185- "pdf:producer" : "PDFKit.NET 4.0.102.0" ,
186- "xap:createdate" : "2018-12-27T13:50:36-08:00" ,
187- "xap:creatortool" : "" ,
188- "xap:metadatadate" : "2018-12-27T13:50:38-08:00" ,
189- "xap:modifydate" : "2018-12-27T13:50:38-08:00" ,
190- } ) ;
163+ expect ( [ ... metadata ] . sort ( ) ) . toEqual ( [
164+ [ "dc:creator" , [ "" ] ] ,
165+ [ "dc:description" , "" ] ,
166+ [ "dc:format" , "application/pdf" ] ,
167+ [ "dc:subject" , [ ] ] ,
168+ [ "dc:title" , "" ] ,
169+ [ "pdf:keywords" , "" ] ,
170+ [ "pdf:pdfversion" , "1.7" ] ,
171+ [ "pdf:producer" , "PDFKit.NET 4.0.102.0" ] ,
172+ [ "xap:createdate" , "2018-12-27T13:50:36-08:00" ] ,
173+ [ "xap:creatortool" , "" ] ,
174+ [ "xap:metadatadate" , "2018-12-27T13:50:38-08:00" ] ,
175+ [ "xap:modifydate" , "2018-12-27T13:50:38-08:00" ] ,
176+ ] ) ;
191177 } ) ;
192178
193179 it ( 'should correctly handle metadata containing "&apos" (issue 10407)' , function ( ) {
@@ -200,13 +186,10 @@ describe("metadata", function () {
200186 "</rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta>" ;
201187 const metadata = createMetadata ( data ) ;
202188
203- expect ( metadata . has ( "dc:title" ) ) . toBeTruthy ( ) ;
204- expect ( metadata . has ( "dc:qux" ) ) . toBeFalsy ( ) ;
205-
206189 expect ( metadata . get ( "dc:title" ) ) . toEqual ( "'Foo bar baz'" ) ;
207190 expect ( metadata . get ( "dc:qux" ) ) . toEqual ( null ) ;
208191
209- expect ( metadata . getAll ( ) ) . toEqual ( { "dc:title" : "'Foo bar baz'" } ) ;
192+ expect ( [ ... metadata ] ) . toEqual ( [ [ "dc:title" , "'Foo bar baz'" ] ] ) ;
210193 } ) ;
211194
212195 it ( "should gracefully handle unbalanced end tags (issue 10410)" , function ( ) {
@@ -229,7 +212,7 @@ describe("metadata", function () {
229212 '</rdf:RDF></x:xmpmeta><?xpacket end="w"?>' ;
230213 const metadata = createMetadata ( data ) ;
231214
232- expect ( metadata . getAll ( ) ) . toEqual ( emptyObj ) ;
215+ expect ( [ ... metadata ] ) . toEqual ( [ ] ) ;
233216 } ) ;
234217
235218 it ( "should not be vulnerable to the billion laughs attack" , function ( ) {
@@ -258,12 +241,9 @@ describe("metadata", function () {
258241 "</rdf:RDF>" ;
259242 const metadata = createMetadata ( data ) ;
260243
261- expect ( metadata . has ( "dc:title" ) ) . toBeTruthy ( ) ;
262- expect ( metadata . has ( "dc:qux" ) ) . toBeFalsy ( ) ;
263-
264244 expect ( metadata . get ( "dc:title" ) ) . toEqual ( "a&lol9;b" ) ;
265245 expect ( metadata . get ( "dc:qux" ) ) . toEqual ( null ) ;
266246
267- expect ( metadata . getAll ( ) ) . toEqual ( { "dc:title" : "a&lol9;b" } ) ;
247+ expect ( [ ... metadata ] ) . toEqual ( [ [ "dc:title" , "a&lol9;b" ] ] ) ;
268248 } ) ;
269249} ) ;
0 commit comments