-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tests to use inline snapshots
- Loading branch information
Showing
9 changed files
with
120 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import plist from "../src/index"; | ||
|
||
it("Throws an error on improperly formatted plist", () => { | ||
function doIt() { | ||
return plist.readFileSync(`${__dirname}/test-xml1-invalid.plist`); | ||
} | ||
const doIt = () => plist.readFileSync(`${__dirname}/test-xml1-invalid.plist`); | ||
expect(doIt).toThrow(); | ||
}); | ||
|
||
it("returns an empty object when the file is zero bytes", () => { | ||
const obj = plist.readFileSync(`${__dirname}/test-xml1-invalid-2.plist`); | ||
expect(obj).toEqual({}); | ||
expect(obj).toMatchInlineSnapshot(`Object {}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import plist from "../src/index"; | ||
import { DemoFile } from "./utils/types"; | ||
|
||
describe("String parsing", () => { | ||
it("can parse a string", () => { | ||
const doc = plist.readFileSync(`${__dirname}/test-binary1.plist`); | ||
const doc = plist.readFileSync<DemoFile>(`${__dirname}/test-binary1.plist`); | ||
const plistString = plist.stringify(doc); | ||
const parsedDoc = plist.parse(plistString); | ||
|
||
return expect(parsedDoc).toEqual(doc); | ||
return expect(parsedDoc).toMatchInlineSnapshot(` | ||
Object { | ||
"Birth Year": 1942, | ||
"Name": "John Doe", | ||
"Travel Log": Array [ | ||
"Tokyo, Honshu, Japan", | ||
"Philadelphia, PA", | ||
"Recife, Pernambuco, Brazil", | ||
], | ||
} | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type DemoFile = { | ||
"Birth Year": number; | ||
Name: string; | ||
"Travel Log": string[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters