@@ -2,6 +2,7 @@ import { redirect } from "../../core/redirect";
22import type { FramesContext } from "../../core/types" ;
33import { neynarValidate } from "." ;
44import type { ValidateFrameActionResponse } from "./types.message" ;
5+ import nock , { cleanAll } from "nock" ;
56
67describe ( "neynarValidate middleware" , ( ) => {
78 let sampleFrameActionRequest : Request ;
@@ -17,6 +18,7 @@ describe("neynarValidate middleware", () => {
1718 untrustedData : { } ,
1819 } ) ,
1920 } ) ;
21+ cleanAll ( ) ;
2022 } ) ;
2123
2224 it ( "moves to next middleware without parsing if request is not POST request" , async ( ) => {
@@ -72,6 +74,48 @@ describe("neynarValidate middleware", () => {
7274 const mw = neynarValidate ( ) ;
7375 const next = jest . fn ( ( ) => Promise . resolve ( new Response ( ) ) ) ;
7476
77+ nock ( "https://api.neynar.com" )
78+ . post ( "/v2/farcaster/frame/validate" )
79+ . reply ( 200 , {
80+ valid : true ,
81+ action : {
82+ object : "validated_frame_action" ,
83+ url : "��i���j����+i̾~��z��q�Z��" ,
84+ interactor : {
85+ object : "user" ,
86+ fid : 18949 ,
87+ username : "ntestn" ,
88+ display_name : "NeynNet Tester" ,
89+ pfp_url :
90+ "https://cdn-icons-png.freepik.com/256/17028/17028049.png?semt=ais_hybrid" ,
91+ custody_address : "0xa5b36877f62a6a07895acd72c0ca60c998a33187" ,
92+ profile : {
93+ bio : {
94+ text : "from the terminal" ,
95+ } ,
96+ } ,
97+ follower_count : 493 ,
98+ following_count : 6 ,
99+ verifications : [ ] ,
100+ verified_addresses : {
101+ eth_addresses : [ ] ,
102+ sol_addresses : [ ] ,
103+ } ,
104+ verified_accounts : null ,
105+ power_badge : false ,
106+ } ,
107+ tapped_button : {
108+ index : 2 ,
109+ } ,
110+ state : {
111+ serialized : "" ,
112+ } ,
113+ cast : { } ,
114+ timestamp : "2024-01-29T05:36:54.000Z" ,
115+ } ,
116+ signature_temporary_object : { } ,
117+ } ) ;
118+
75119 await mw ( context , next ) ;
76120
77121 expect ( next ) . toHaveBeenCalledWith (
@@ -95,5 +139,4 @@ describe("neynarValidate middleware", () => {
95139 } )
96140 ) ;
97141 } ) ;
98-
99142} ) ;
0 commit comments