Skip to content

Commit

Permalink
fix: neynar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephancill authored and davidfurlong committed Oct 24, 2024
1 parent d0af8da commit aec8740
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion packages/frames.js/src/middleware/neynar/neynarValidate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { redirect } from "../../core/redirect";
import type { FramesContext } from "../../core/types";
import { neynarValidate } from ".";
import type { ValidateFrameActionResponse } from "./types.message";
import nock, { cleanAll } from "nock";

describe("neynarValidate middleware", () => {
let sampleFrameActionRequest: Request;
Expand All @@ -17,6 +18,7 @@ describe("neynarValidate middleware", () => {
untrustedData: {},
}),
});
cleanAll();
});

it("moves to next middleware without parsing if request is not POST request", async () => {
Expand Down Expand Up @@ -72,6 +74,48 @@ describe("neynarValidate middleware", () => {
const mw = neynarValidate();
const next = jest.fn(() => Promise.resolve(new Response()));

nock("https://api.neynar.com")
.post("/v2/farcaster/frame/validate")
.reply(200, {
valid: true,
action: {
object: "validated_frame_action",
url: "��i���j����+i̾~��z��q�Z��",
interactor: {
object: "user",
fid: 18949,
username: "ntestn",
display_name: "NeynNet Tester",
pfp_url:
"https://cdn-icons-png.freepik.com/256/17028/17028049.png?semt=ais_hybrid",
custody_address: "0xa5b36877f62a6a07895acd72c0ca60c998a33187",
profile: {
bio: {
text: "from the terminal",
},
},
follower_count: 493,
following_count: 6,
verifications: [],
verified_addresses: {
eth_addresses: [],
sol_addresses: [],
},
verified_accounts: null,
power_badge: false,
},
tapped_button: {
index: 2,
},
state: {
serialized: "",
},
cast: {},
timestamp: "2024-01-29T05:36:54.000Z",
},
signature_temporary_object: {},
});

await mw(context, next);

expect(next).toHaveBeenCalledWith(
Expand All @@ -95,5 +139,4 @@ describe("neynarValidate middleware", () => {
})
);
});

});

0 comments on commit aec8740

Please sign in to comment.