-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr/watch) flush: sync watchers should work in ssr (#6139)
fix #6013
- Loading branch information
1 parent
32b5124
commit 0e09761
Showing
5 changed files
with
64 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createSSRApp, defineComponent, h, watch, ref } from 'vue' | ||
import { SSRContext, renderToString } from '../src' | ||
|
||
describe('ssr: watch', () => { | ||
// #6013 | ||
test('should work w/ flush:sync', async () => { | ||
const App = defineComponent(() => { | ||
const count = ref(0) | ||
let msg = '' | ||
watch( | ||
count, | ||
() => { | ||
msg = 'hello world' | ||
}, | ||
{ flush: 'sync' } | ||
) | ||
count.value = 1 | ||
expect(msg).toBe('hello world') | ||
return () => h('div', null, msg) | ||
}) | ||
|
||
const app = createSSRApp(App) | ||
const ctx: SSRContext = {} | ||
const html = await renderToString(app, ctx) | ||
|
||
expect(ctx.__watcherHandles!.length).toBe(1) | ||
|
||
expect(html).toMatch('hello world') | ||
}) | ||
}) |
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