-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable ssr by default for analog platform plugin (#301)
- Loading branch information
1 parent
2267afc
commit 95aa678
Showing
6 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
} | ||
}, | ||
"test": { | ||
"dependsOn": ["^build"], | ||
"executor": "@nrwl/vite:test" | ||
} | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { describe, expect } from 'vitest'; | ||
import { platformPlugin } from './platform-plugin'; | ||
|
||
vi.mock('./vite-nitro-plugin'); | ||
vi.mock('./ssr/ssr-build-plugin'); | ||
vi.mock('./ssr/dev-server-plugin'); | ||
|
||
describe('platformPlugin', () => { | ||
const setup = async () => { | ||
const viteNitroPluginImport = await import('./vite-nitro-plugin'); | ||
const viteNitroPluginSpy = vi.fn(); | ||
viteNitroPluginImport.viteNitroPlugin = viteNitroPluginSpy; | ||
|
||
const ssrBuildPluginImport = await import('./ssr/ssr-build-plugin'); | ||
const ssrBuildPluginSpy = vi.fn(); | ||
ssrBuildPluginImport.ssrBuildPlugin = ssrBuildPluginSpy; | ||
|
||
const devServerPluginImport = await import('./ssr/dev-server-plugin'); | ||
const devServerPluginSpy = vi.fn(); | ||
devServerPluginImport.devServerPlugin = devServerPluginSpy; | ||
|
||
return { | ||
viteNitroPluginSpy, | ||
ssrBuildPluginSpy, | ||
devServerPluginSpy, | ||
platformPlugin, | ||
}; | ||
}; | ||
|
||
it('should default ssr to true and pass that value to other plugins if no ssr value provided in options', async () => { | ||
const { | ||
viteNitroPluginSpy, | ||
ssrBuildPluginSpy, | ||
devServerPluginSpy, | ||
platformPlugin, | ||
} = await setup(); | ||
platformPlugin(); | ||
|
||
expect(viteNitroPluginSpy).toHaveBeenCalledWith({ ssr: true }, undefined); | ||
expect(ssrBuildPluginSpy).toHaveBeenCalled(); | ||
expect(devServerPluginSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should pass ssr value as true if options.ssr is set to true', async () => { | ||
const { | ||
viteNitroPluginSpy, | ||
ssrBuildPluginSpy, | ||
devServerPluginSpy, | ||
platformPlugin, | ||
} = await setup(); | ||
platformPlugin({ ssr: true }); | ||
|
||
expect(viteNitroPluginSpy).toHaveBeenCalledWith({ ssr: true }, undefined); | ||
expect(ssrBuildPluginSpy).toHaveBeenCalled(); | ||
expect(devServerPluginSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should pass ssr value as false if options.ssr is set to false', async () => { | ||
const { | ||
viteNitroPluginSpy, | ||
ssrBuildPluginSpy, | ||
devServerPluginSpy, | ||
platformPlugin, | ||
} = await setup(); | ||
platformPlugin({ ssr: false }); | ||
|
||
expect(viteNitroPluginSpy).toHaveBeenCalledWith({ ssr: false }, undefined); | ||
expect(ssrBuildPluginSpy).not.toHaveBeenCalled(); | ||
expect(devServerPluginSpy).not.toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters