11import { describe , it , expect } from 'vitest' ;
22
3+ import type { StatsResponse } from './stats.schema.ts' ;
34import testCors from '../utils/spec/cors.ts' ;
45import testHuman from '../utils/spec/human.ts' ;
56import { beforeRequest , request } from '../utils/spec/request.ts' ;
@@ -20,22 +21,22 @@ describe('/stats', () => {
2021 } ) ;
2122 it ( 'returns a JSON body that is a stats object' , async ( ) => {
2223 expect ( response . headers . get ( 'Content-Type' ) ) . to . match ( / a p p l i c a t i o n \/ j s o n / ) ;
23- expect ( await response . json ( ) ) . to . be . an ( 'object' ) ;
24+ expect ( await response . json < StatsResponse > ( ) ) . to . be . an ( 'object' ) ;
2425 } ) ;
2526 describe ( 'cdnjs stats object' , ( ) => {
2627 it ( 'is an object with the \'libraries\' property' , async ( ) => {
27- expect ( await response . json ( ) ) . to . have . property ( 'libraries' ) . that . is . an ( 'number' ) ;
28+ expect ( await response . json < StatsResponse > ( ) ) . to . have . property ( 'libraries' ) . that . is . an ( 'number' ) ;
2829 } ) ;
2930 it ( 'has no other properties' , async ( ) => {
30- expect ( Object . keys ( await response . json ( ) ) ) . to . have . lengthOf ( 1 ) ;
31+ expect ( Object . keys ( await response . json < StatsResponse > ( ) ) ) . to . have . lengthOf ( 1 ) ;
3132 } ) ;
3233 } ) ;
3334
3435 // Test with a trailing slash
3536 it ( 'responds to requests with a trailing slash' , async ( ) => {
3637 const res = await request ( path + '/' ) ;
3738 expect ( res . status ) . to . eq ( 200 ) ;
38- expect ( await res . json ( ) ) . to . deep . equal ( await response . json ( ) ) ;
39+ expect ( await res . json < StatsResponse > ( ) ) . to . deep . equal ( await response . json < StatsResponse > ( ) ) ;
3940 } ) ;
4041 } ) ;
4142
0 commit comments