Skip to content

Commit

Permalink
test: add test for getRelayInformation query
Browse files Browse the repository at this point in the history
  • Loading branch information
bob2402 committed Apr 6, 2024
1 parent 0950240 commit 47cfe67
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions queries/getRelayInfomation.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query getRelayInformation {
relayInformation {
name
contact
description
icon
pubkey
software
supported_nips
version
}
}
14 changes: 14 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ Deno.test("NIP-11: Relay Information Document", async (t) => {
assertEquals(information2, { name: "Nostr Relay2", ...not_modifiable_information });
});

await t.step("graphql", async () => {
const { hostname, port } = new URL(relay.url);
const res = await fetch(`http://${hostname}:${port}/api`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"password": "123",
},
body: JSON.stringify({ query: await Deno.readTextFile("./queries/getRelayInfomation.gql") }),
});
const json = await res.json();
assertEquals(json.data.relayInformation.name, "Nostr Relay2");
});

await relay.shutdown();
});

Expand Down

0 comments on commit 47cfe67

Please sign in to comment.