Skip to content

Commit

Permalink
stable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Jan 4, 2025
1 parent 4439ac2 commit 367dc96
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 5 additions & 9 deletions packages/rescript-relay/__tests__/Test_catch-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("Catch", () => {
});

t.render(test_catch("TestLoggedInUserProp"));
await t.screen.findByText("Got createdAt: 1735707600000");
await t.screen.findByText("Got createdAt: 2025-01-01");
});

test("logged in user prop - fail", async () => {
Expand Down Expand Up @@ -51,7 +51,7 @@ describe("Catch", () => {
});

t.render(test_catch("TestLoggedInUserPropFragmentData"));
await t.screen.findByText("Got createdAt: 1735707600000");
await t.screen.findByText("Got createdAt: 2025-01-01");
});

test("logged in user prop from fragment - fail", async () => {
Expand Down Expand Up @@ -83,9 +83,7 @@ describe("Catch", () => {
});

t.render(test_catch("TestMember"));
await t.screen.findByText(
"Got user id: user-1, and createdAt: 1735707600000"
);
await t.screen.findByText("Got user id: user-1, and createdAt: 2025-01-01");
});

test("member prop - fail", async () => {
Expand Down Expand Up @@ -118,9 +116,7 @@ describe("Catch", () => {
});

t.render(test_catch("TestMemberNested"));
await t.screen.findByText(
"Got user id: user-1, and createdAt: 1735707600000"
);
await t.screen.findByText("Got user id: user-1, and createdAt: 2025-01-01");
});

test("member prop - fail nested", async () => {
Expand Down Expand Up @@ -182,7 +178,7 @@ describe("Catch", () => {

t.render(test_catch("TestMembers"));
await t.screen.findByText(
"User: user-1 - 1735707600000, Error!, User: user-3 - 1735707600000"
"User: user-1 - 2025-01-01, Error!, User: user-3 - 2025-01-01"
);
});
});
14 changes: 9 additions & 5 deletions packages/rescript-relay/__tests__/Test_catch.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ module TestLoggedInUserProp = {
switch query.loggedInUser.createdAt {
| Ok({value: createdAt}) =>
<div>
{React.string("Got createdAt: " ++ createdAt->Js.Date.getTime->Belt.Float.toString)}
{React.string(
"Got createdAt: " ++ createdAt->Js.Date.toISOString->Js.String2.slice(~from=0, ~to_=10),
)}
</div>
| Error(_) => <div> {React.string("Error!")} </div>
}
Expand All @@ -37,7 +39,9 @@ module TestLoggedInUserPropFragmentData = {
switch fragmentData {
| Ok({value: {createdAt}}) =>
<div>
{React.string("Got createdAt: " ++ createdAt->Js.Date.getTime->Belt.Float.toString)}
{React.string(
"Got createdAt: " ++ createdAt->Js.Date.toISOString->Js.String2.slice(~from=0, ~to_=10),
)}
</div>
| Error(_) => <div> {React.string("Error!")} </div>
}
Expand Down Expand Up @@ -67,7 +71,7 @@ module TestMember = {
"Got user id: " ++
id ++
", and createdAt: " ++
createdAt->Js.Date.getTime->Belt.Float.toString,
createdAt->Js.Date.toISOString->Js.String2.slice(~from=0, ~to_=10),
)}
</div>
| Error(_) => <div> {React.string("Error!")} </div>
Expand Down Expand Up @@ -104,7 +108,7 @@ module TestMemberNested = {
"Got user id: " ++
id ++
", and createdAt: " ++
createdAt->Js.Date.getTime->Belt.Float.toString,
createdAt->Js.Date.toISOString->Js.String2.slice(~from=0, ~to_=10),
)}
</div>
| Some(User({memberOfSingular: Error(_)})) => <div> {React.string("Error nested!")} </div>
Expand Down Expand Up @@ -143,7 +147,7 @@ module TestMembers = {
->Js.Array2.map(r =>
switch r {
| Ok({value: User({id, createdAt})}) =>
`User: ${id} - ${createdAt->Js.Date.getTime->Belt.Float.toString}`
`User: ${id} - ${createdAt->Js.Date.toISOString->Js.String2.slice(~from=0, ~to_=10)}`
| _ => "Error!"
}
)
Expand Down
2 changes: 2 additions & 0 deletions packages/rescript-relay/__tests__/TestsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ exception Malformed_date
exception Malformed_number

module Datetime = {
@editor.completeFrom(Js.Date)
type t = Js.Date.t

let parse = t =>
switch t->Js.Json.decodeString {
| None => raise(Malformed_date)
Expand Down

0 comments on commit 367dc96

Please sign in to comment.