Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RawToast committed Mar 25, 2018
1 parent b1cfbb0 commit b6c2f94
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions dokusho/src/test/Decoder_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,43 @@ describe("Decoders", () => {
expect("Else" |> Decoders.parsePageType) |> toBe(Book);
});
});

let entryStr = "{\"id\": 1, \"kind\": \"Book\", \"value\": 1}";
let dayStr = "{\"date\": \"2018-03-25T00:00\", \"entries\": [" ++ entryStr ++ "]}";
let historyStr = "{ \"days\": [" ++ dayStr++"]}";

describe("Decoders.parseEnry", () => {
test("Can parse valid json into an entry", () =>
expect(entryStr
|> Json.parseOrRaise
|> Decoders.parseEntry)
|> toEqual({id: 1, kind: Book, value: 1}))
});

describe("Decoders.parseDay", () => {
test("Can parse valid json into a day", () =>
expect(dayStr
|> Json.parseOrRaise
|> Decoders.parseDay)
|> toEqual(
{date: "2018-03-25T00:00", entries:[{id: 1, kind: Book, value: 1}]}
))
});

describe("Decoders.parseHistory", () => {
test("Can parse valid json into a reading history", () =>
expect(historyStr
|> Json.parseOrRaise
|> Decoders.parseHistory)
|> toEqual({
days: [
{
date: "2018-03-25T00:00",
entries:[{id: 1, kind: Book, value: 1}]
}
]
}
))
});

});

0 comments on commit b6c2f94

Please sign in to comment.