@@ -6,7 +6,7 @@ import { resolveCodeServerOptions, setup } from '../src/integrations/code-server
66
77const mocks = vi . hoisted ( ( ) => ( {
88createCodeServerDevframe : vi . fn ( ) ,
9- mountDevframe : vi . fn ( ) ,
9+ install : vi . fn ( ) ,
1010setupCodeServer : vi . fn ( ) ,
1111dispose : vi . fn ( ) ,
1212} ) )
@@ -19,10 +19,6 @@ vi.mock('@devframes/plugin-code-server/node', () => ({
1919setupCodeServer : mocks . setupCodeServer ,
2020} ) )
2121
22- vi . mock ( '@vitejs/devtools-kit/node' , ( ) => ( {
23- mountDevframe : mocks . mountDevframe ,
24- } ) )
25-
2622function fakeContext ( moduleOptions : Record < string , any > = { } ) {
2723const hooks = createHooks ( )
2824const nuxt = {
@@ -52,7 +48,7 @@ beforeEach(() => {
5248setup : vi . fn ( ) ,
5349} ) )
5450mocks . setupCodeServer . mockResolvedValue ( { dispose : mocks . dispose } )
55- mocks . mountDevframe . mockImplementation ( async ( _kit , definition ) => {
51+ mocks . install . mockImplementation ( async ( definition ) => {
5652await definition . setup ( { cwd : '/project' } )
5753} )
5854} )
@@ -114,7 +110,7 @@ describe('code server setup', () => {
114110await nuxt . callHook ( 'devtools:ready' , { } as any )
115111
116112expect ( mocks . createCodeServerDevframe ) . not . toHaveBeenCalled ( )
117- expect ( mocks . mountDevframe ) . not . toHaveBeenCalled ( )
113+ expect ( mocks . install ) . not . toHaveBeenCalled ( )
118114} )
119115
120116it ( 'mounts the plugin in the Nuxt group and disposes its supervisor on close' , async ( ) => {
@@ -127,10 +123,9 @@ describe('code server setup', () => {
127123serverPort : 9090 ,
128124} ) )
129125
130- const kit = { id : 'kit' }
126+ const kit = { id : 'kit' , install : mocks . install }
131127await nuxt . callHook ( 'devtools:ready' , kit as any )
132- expect ( mocks . mountDevframe ) . toHaveBeenCalledWith (
133- kit ,
128+ expect ( mocks . install ) . toHaveBeenCalledWith (
134129expect . objectContaining ( { id : 'devframes_plugin_code-server' } ) ,
135130{
136131dock : {
@@ -157,7 +152,7 @@ describe('code server setup', () => {
157152const { ctx, nuxt } = fakeContext ( )
158153setup ( ctx )
159154
160- const ready = nuxt . callHook ( 'devtools:ready' , { id : 'kit' } as any )
155+ const ready = nuxt . callHook ( 'devtools:ready' , { id : 'kit' , install : mocks . install } as any )
161156await vi . waitFor ( ( ) => {
162157expect ( mocks . setupCodeServer ) . toHaveBeenCalledOnce ( )
163158} )
0 commit comments