@@ -6,8 +6,23 @@ import { describe, expect, test } from 'vitest'
6
6
import { FixtureTestContext , setupFixtureTests } from '../../utils/fixture.js'
7
7
import got from '../../utils/got.cjs'
8
8
9
+ const siteInfo = {
10
+ account_id : 'mock-account-id' ,
11
+ account_slug : 'mock-account' ,
12
+ id : 'mock-site-id' ,
13
+ name : 'mock-site-name' ,
14
+ }
15
+ const routes = [
16
+ { path : 'sites/*/service-instances' , response : [ ] } ,
17
+ { path : 'sites/*' , response : siteInfo } ,
18
+ {
19
+ path : 'accounts' ,
20
+ response : [ { id : siteInfo . account_id , slug : siteInfo . account_slug } ] ,
21
+ } ,
22
+ ]
23
+
9
24
describe . runIf ( gte ( version , '18.13.0' ) ) ( 'v2 api' , ( ) => {
10
- setupFixtureTests ( 'dev-server-with-v2-functions' , { devServer : true } , ( ) => {
25
+ setupFixtureTests ( 'dev-server-with-v2-functions' , { devServer : true , mockApi : { routes } } , ( ) => {
11
26
test < FixtureTestContext > ( 'should successfully be able to run v2 functions' , async ( { devServer } ) => {
12
27
const response = await got ( `http://localhost:${ devServer . port } /.netlify/functions/ping` , {
13
28
throwHttpErrors : false ,
@@ -54,6 +69,8 @@ describe.runIf(gte(version, '18.13.0'))('v2 api', () => {
54
69
expect ( context . geo . city ) . toEqual ( 'Mock City' )
55
70
56
71
expect ( context . cookies ) . toEqual ( { foo : 'bar' } )
72
+
73
+ expect ( context . account . id ) . toEqual ( 'mock-account-id' )
57
74
} )
58
75
59
76
test < FixtureTestContext > ( 'logging works' , async ( { devServer } ) => {
0 commit comments