computed.spec.ts — vue Source File
Architecture documentation for computed.spec.ts, a typescript file in the vue codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 131232d5_fb0a_ae65_6559_3970171367ff["computed.spec.ts"] d970b406_3424_b00e_55dd_82e98ab5aac2["v3"] 131232d5_fb0a_ae65_6559_3970171367ff --> d970b406_3424_b00e_55dd_82e98ab5aac2 1a5e86bd_1a43_1523_b480_a1b1a98c87ad["effect"] 131232d5_fb0a_ae65_6559_3970171367ff --> 1a5e86bd_1a43_1523_b480_a1b1a98c87ad 6d8f8976_7066_720b_0d45_45fe42921eaf["util"] 131232d5_fb0a_ae65_6559_3970171367ff --> 6d8f8976_7066_720b_0d45_45fe42921eaf 3897e8b5_9242_b5d7_bf5f_783d40cceb59["index"] 131232d5_fb0a_ae65_6559_3970171367ff --> 3897e8b5_9242_b5d7_bf5f_783d40cceb59 style 131232d5_fb0a_ae65_6559_3970171367ff fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import {
computed,
reactive,
ref,
isReadonly,
WritableComputedRef,
DebuggerEvent,
TrackOpTypes,
TriggerOpTypes
} from 'v3'
import { effect } from 'v3/reactivity/effect'
import { nextTick } from 'core/util'
import { set, del } from 'core/observer/index'
describe('reactivity/computed', () => {
it('should return updated value', () => {
const value = reactive({ foo: 1 })
const cValue = computed(() => value.foo)
expect(cValue.value).toBe(1)
value.foo = 2
expect(cValue.value).toBe(2)
})
it('should compute lazily', () => {
const value = reactive<{ foo?: number }>({ foo: undefined })
const getter = vi.fn(() => value.foo)
const cValue = computed(getter)
// lazy
expect(getter).not.toHaveBeenCalled()
expect(cValue.value).toBe(undefined)
expect(getter).toHaveBeenCalledTimes(1)
// should not compute again
cValue.value
expect(getter).toHaveBeenCalledTimes(1)
// should not compute until needed
value.foo = 1
expect(getter).toHaveBeenCalledTimes(1)
// now it should compute
expect(cValue.value).toBe(1)
expect(getter).toHaveBeenCalledTimes(2)
// should not compute again
cValue.value
expect(getter).toHaveBeenCalledTimes(2)
})
it('should trigger effect', () => {
const value = reactive<{ foo?: number }>({ foo: undefined })
const cValue = computed(() => value.foo)
let dummy
effect(() => {
dummy = cValue.value
})
expect(dummy).toBe(undefined)
value.foo = 1
// ... (242 more lines)
Dependencies
- effect
- index
- util
- v3
Source
Frequently Asked Questions
What does computed.spec.ts do?
computed.spec.ts is a source file in the vue codebase, written in typescript.
What does computed.spec.ts depend on?
computed.spec.ts imports 4 module(s): effect, index, util, v3.
Where is computed.spec.ts in the architecture?
computed.spec.ts is located at test/unit/features/v3/reactivity/computed.spec.ts (directory: test/unit/features/v3/reactivity).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free