shallowReadonly.spec.ts — vue Source File
Architecture documentation for shallowReadonly.spec.ts, a typescript file in the vue codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8417fe83_7cc6_efe7_4d7e_dc853b1a5bd0["shallowReadonly.spec.ts"] d970b406_3424_b00e_55dd_82e98ab5aac2["v3"] 8417fe83_7cc6_efe7_4d7e_dc853b1a5bd0 --> d970b406_3424_b00e_55dd_82e98ab5aac2 style 8417fe83_7cc6_efe7_4d7e_dc853b1a5bd0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { isReactive, shallowReadonly, readonly, isReadonly } from 'v3'
describe('reactivity/shallowReadonly', () => {
test('should be readonly', () => {
expect(isReadonly(shallowReadonly({}))).toBe(true)
})
test('should not make non-reactive properties reactive', () => {
const props = shallowReadonly({ n: { foo: 1 } })
expect(isReactive(props.n)).toBe(false)
})
test('should make root level properties readonly', () => {
const props = shallowReadonly({ n: 1 })
// @ts-expect-error
props.n = 2
expect(props.n).toBe(1)
expect(
`Set operation on key "n" failed: target is readonly.`
).toHaveBeenWarned()
})
// to retain 2.x behavior.
test('should NOT make nested properties readonly', () => {
const props = shallowReadonly({ n: { foo: 1 } })
props.n.foo = 2
expect(props.n.foo).toBe(2)
expect(
`Set operation on key "foo" failed: target is readonly.`
).not.toHaveBeenWarned()
})
// #2843
test('should differentiate from normal readonly calls', () => {
const original = { foo: {} }
const shallowProxy = shallowReadonly(original)
const reactiveProxy = readonly(original)
expect(shallowProxy).not.toBe(reactiveProxy)
expect(isReadonly(shallowProxy.foo)).toBe(false)
expect(isReadonly(reactiveProxy.foo)).toBe(true)
})
// @discrepancy does not support collections
// describe('collection/Map', () => {
// ;[Map, WeakMap].forEach(Collection => {
// test('should make the map/weak-map readonly', () => {
// const key = {}
// const val = { foo: 1 }
// const original = new Collection([[key, val]])
// const sroMap = shallowReadonly(original)
// expect(isReadonly(sroMap)).toBe(true)
// expect(isReactive(sroMap)).toBe(false)
// expect(sroMap.get(key)).toBe(val)
// sroMap.set(key, {} as any)
// expect(
// `Set operation on key "[object Object]" failed: target is readonly.`
// ).toHaveBeenWarned()
// })
// ... (147 more lines)
Dependencies
- v3
Source
Frequently Asked Questions
What does shallowReadonly.spec.ts do?
shallowReadonly.spec.ts is a source file in the vue codebase, written in typescript.
What does shallowReadonly.spec.ts depend on?
shallowReadonly.spec.ts imports 1 module(s): v3.
Where is shallowReadonly.spec.ts in the architecture?
shallowReadonly.spec.ts is located at test/unit/features/v3/reactivity/shallowReadonly.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