Skip to content

Commit

Permalink
test: add resetSuspenseId
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 3, 2024
1 parent 3659ae5 commit 3e3ff41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/runtime-core/__tests__/components/Suspense.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import {
} from '@vue/runtime-test'
import { createApp, defineComponent } from 'vue'
import type { RawSlots } from 'packages/runtime-core/src/componentSlots'
import { resetSuspenseId } from '../../src/components/Suspense'

describe('Suspense', () => {
const deps: Promise<any>[] = []

beforeEach(() => {
deps.length = 0
resetSuspenseId()
})

// a simple async factory for testing purposes only.
Expand Down
5 changes: 5 additions & 0 deletions packages/runtime-core/src/components/Suspense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export const isSuspense = (type: any): boolean => type.__isSuspense
// incrementing unique id for every pending branch
let suspenseId = 0

/**
* For testing only
*/
export const resetSuspenseId = () => (suspenseId = 0)

// Suspense exposes a component-like API, and is treated like a component
// in the compiler, but internally it's a special built-in type that hooks
// directly into the renderer.
Expand Down

0 comments on commit 3e3ff41

Please sign in to comment.