Skip to content

Commit

Permalink
up test project
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Apr 21, 2024
1 parent 79db305 commit 9419f32
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 40 deletions.
48 changes: 24 additions & 24 deletions dbTestProject/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dbTestProject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"author": "",
"license": "ISC",
"dependencies": {
"@rescript/core": "1.0.0",
"rescript": "^11.1.0-rc.2",
"rescript-edgedb": "0.6.0",
"@rescript/core": "1.3.0",
"rescript": "^11.1.0",
"rescript-edgedb": "0.7.0",
"rescript-embed-lang": "0.4.0"
}
}
25 changes: 25 additions & 0 deletions dbTestProject/rescript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "res",
"uncurried": true,
"sources": [
{
"dir": "src",
"subdirs": true
},
{
"dir": "test",
"type": "dev"
},
{
"dir": "../src"
}
],
"package-specs": {
"module": "esmodule",
"in-source": true
},
"suffix": ".mjs",
"bs-dependencies": ["@rescript/core", "rescript-edgedb"],
"bsc-flags": ["-open RescriptCore"],
"ppx-flags": ["rescript-embed-lang/ppx"]
}
18 changes: 10 additions & 8 deletions dbTestProject/test/TestProject.test.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ afterAllAsync(async () => {
await client->EdgeDB.Client.close
})

let removeIds = (key, value) => {
switch (key, value) {
| ("id", Js.Json.String(_)) => Js.Json.String("<id>")
| _ => value
}
}
let removeIds = JSON.Replacer(
(key, value) => {
switch (key, value) {
| ("id", Js.Json.String(_)) => Js.Json.String("<id>")
| _ => value
}
},
)

describe("fetching data", () => {
testAsync("fetching movies", async () => {
let movies = await client->Movies.allMovies
let movies = movies->JSON.stringifyAnyWithReplacerAndIndent(removeIds, 2)->Option.getOr("")
let movies = movies->JSON.stringifyAny(~replacer=removeIds, ~space=2)->Option.getOr("")
expect(movies)->Expect.toMatchSnapshot
})

testAsync("fetching single movie", async () => {
let movie = await client->Movies.movieByTitle(~title="The Great Adventure")
let movie = movie->JSON.stringifyAnyWithReplacerAndIndent(removeIds, 2)->Option.getOr("")
let movie = movie->JSON.stringifyAny(~replacer=removeIds, ~space=2)->Option.getOr("")
expect(movie)->Expect.toMatchSnapshot
})

Expand Down
10 changes: 5 additions & 5 deletions dbTestProject/test/__snapshots__/TestProject.test.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ exports[`run unused selections CLI 1`] = `
✘ Found 4 unused selections.
File "Movies":
File "Movies.res":
In query "AllMovies":
- actors: numberOfPets
- title
- actors.numberOfPets
- .title
In query "MovieByTitle":
- actors: name
- id
- actors.name
- .id
"
`;

0 comments on commit 9419f32

Please sign in to comment.