makeReadOnly-test.ts — react Source File
Architecture documentation for makeReadOnly-test.ts, a typescript file in the react codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 9d3f0d29_1a88_4136_a1d9_f33cb8e7eac9["makeReadOnly-test.ts"] d6c796a8_fd31_85fd_3d28_009b4955a0c4["makeReadOnly.ts"] 9d3f0d29_1a88_4136_a1d9_f33cb8e7eac9 --> d6c796a8_fd31_85fd_3d28_009b4955a0c4 13c9557e_a777_aa57_3631_07e98c11165f["buildMakeReadOnly"] 9d3f0d29_1a88_4136_a1d9_f33cb8e7eac9 --> 13c9557e_a777_aa57_3631_07e98c11165f style 9d3f0d29_1a88_4136_a1d9_f33cb8e7eac9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import buildMakeReadOnly from '../makeReadOnly';
describe('makeReadOnly', () => {
let logger: jest.Func;
let makeReadOnly: <T>(value: T, source: string) => T;
beforeEach(() => {
logger = jest.fn();
makeReadOnly = buildMakeReadOnly(logger, []);
});
describe('Tracking mutations', () => {
it('can be called with all primitives', () => {
const a = 5;
const b = true;
const c = null;
expect(makeReadOnly(a, 'test1')).toBe(a);
expect(makeReadOnly(b, 'test1')).toBe(b);
expect(makeReadOnly(c, 'test1')).toBe(c);
});
it('retains referential equality', () => {
const valA = {};
const valB = {a: valA, _: valA};
const o = {a: valA, b: valB, c: 'c'};
expect(makeReadOnly(o, 'test2')).toBe(o);
expect(makeReadOnly(o.a, 'test2')).toBe(valA);
expect(makeReadOnly(o.b, 'test2')).toBe(valB);
expect(makeReadOnly(o.b.a, 'test2')).toBe(valA);
expect(makeReadOnly(o.b._, 'test2')).toBe(valA);
expect(makeReadOnly(o.c, 'test2')).toBe('c');
});
it('deals with cyclic references', () => {
const o: any = {};
o.self_ref = o;
expect(makeReadOnly(o, 'test3')).toBe(o);
expect(makeReadOnly(o.self_ref, 'test3')).toBe(o);
});
it('logs direct interior mutability', () => {
const o = {a: 0};
makeReadOnly(o, 'test4');
o.a = 42;
expect(logger).toBeCalledWith('FORGET_MUTATE_IMMUT', 'test4', 'a', 42);
});
it('tracks changes to known RO properties', () => {
const o: any = {a: {}};
makeReadOnly(o, 'test5');
o.a = 42;
expect(logger).toBeCalledWith('FORGET_MUTATE_IMMUT', 'test5', 'a', 42);
expect(o.a).toBe(42);
const newVal = {x: 0};
// ... (107 more lines)
Domain
Dependencies
Source
Frequently Asked Questions
What does makeReadOnly-test.ts do?
makeReadOnly-test.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain.
What does makeReadOnly-test.ts depend on?
makeReadOnly-test.ts imports 2 module(s): buildMakeReadOnly, makeReadOnly.ts.
Where is makeReadOnly-test.ts in the architecture?
makeReadOnly-test.ts is located at compiler/packages/make-read-only-util/src/__tests__/makeReadOnly-test.ts (domain: BabelCompiler, directory: compiler/packages/make-read-only-util/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free