File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import axios from "axios";
44import MockAdapter from "axios-mock-adapter" ;
55import { expect , it , describe , afterEach } from "@jest/globals" ;
66import { renderGistCard } from "../src/cards/gist-card.js" ;
7+ import { renderError } from "../src/common/utils.js" ;
78import gist from "../api/gist.js" ;
89
910const gist_data = {
@@ -101,4 +102,24 @@ describe("Test /api/gist", () => {
101102 ) ,
102103 ) ;
103104 } ) ;
105+
106+ it ( "should render error if id is not provided" , async ( ) => {
107+ const req = {
108+ query : { } ,
109+ } ;
110+ const res = {
111+ setHeader : jest . fn ( ) ,
112+ send : jest . fn ( ) ,
113+ } ;
114+
115+ await gist ( req , res ) ;
116+
117+ expect ( res . setHeader ) . toBeCalledWith ( "Content-Type" , "image/svg+xml" ) ;
118+ expect ( res . send ) . toBeCalledWith (
119+ renderError (
120+ 'Missing params "id" make sure you pass the parameters in URL' ,
121+ "/api/gist?id=GIST_ID" ,
122+ ) ,
123+ ) ;
124+ } ) ;
104125} ) ;
You can’t perform that action at this time.
0 commit comments