1
1
import plist from "../src/index" ;
2
+ import { DemoFile } from "./utils/types" ;
2
3
3
4
const filePath = `${ __dirname } /test-xml1.plist` ;
4
5
5
- type TestXml1 = {
6
- "Birth Year" : number ;
7
- Name : string ;
8
- "Empty String" : string ;
9
- "Travel Log" : string [ ] ;
10
- } ;
6
+ type TestXml1 = DemoFile & { "Empty String" : string } ;
11
7
12
8
describe ( "readFileSync can properly load and read a file" , ( ) => {
13
9
const contents = plist . readFileSync < TestXml1 > ( filePath ) ;
14
10
it ( "has the proper values" , ( ) => {
15
11
if ( ! contents [ "Name" ] ) {
16
12
fail ( `Failed to parse ${ filePath } ` ) ;
17
13
}
18
- expect ( contents . Name ) . toBe ( "John Doe" ) ;
19
- expect ( contents [ "Birth Year" ] ) . toBe ( 1942 ) ;
20
- expect ( contents [ "Empty String" ] ) . toBe ( "" ) ;
21
- expect ( contents [ "Travel Log" ] ) . toEqual ( [
22
- "Tokyo, Honshu, Japan" ,
23
- "Philadelphia, PA" ,
24
- "Recife, Pernambuco, Brazil" ,
25
- ] ) ;
14
+ expect ( contents ) . toMatchInlineSnapshot ( `
15
+ Object {
16
+ "Birth Year": 1942,
17
+ "Empty String": "",
18
+ "Name": "John Doe",
19
+ "Travel Log": Array [
20
+ "Tokyo, Honshu, Japan",
21
+ "Philadelphia, PA",
22
+ "Recife, Pernambuco, Brazil",
23
+ ],
24
+ }
25
+ ` ) ;
26
26
} ) ;
27
27
} ) ;
28
28
@@ -32,14 +32,18 @@ describe("readFile works asynchronously", () => {
32
32
if ( ! contents ) {
33
33
fail ( `Failed to parse ${ filePath } ` ) ;
34
34
}
35
- expect ( contents . Name ) . toBe ( "John Doe" ) ;
36
- expect ( contents [ "Birth Year" ] ) . toBe ( 1942 ) ;
37
- expect ( contents [ "Empty String" ] ) . toBe ( "" ) ;
38
- expect ( contents [ "Travel Log" ] ) . toEqual ( [
39
- "Tokyo, Honshu, Japan" ,
40
- "Philadelphia, PA" ,
41
- "Recife, Pernambuco, Brazil" ,
42
- ] ) ;
35
+ expect ( contents ) . toMatchInlineSnapshot ( `
36
+ Object {
37
+ "Birth Year": 1942,
38
+ "Empty String": "",
39
+ "Name": "John Doe",
40
+ "Travel Log": Array [
41
+ "Tokyo, Honshu, Japan",
42
+ "Philadelphia, PA",
43
+ "Recife, Pernambuco, Brazil",
44
+ ],
45
+ }
46
+ ` ) ;
43
47
done ( ) ;
44
48
} ) ;
45
49
} ) ;
0 commit comments