Lentil Hoffman 60ad920b30
refactor: update test files to use DeltaBuilder fluent API
- Refactored delta creation in test files to use createDelta() pattern
- Replaced direct Delta instantiations with fluent builder API
- Updated relationship deltas to use setProperty with proper entity context
- Ensured all tests pass with the new delta creation approach

This is part of the ongoing effort to standardize on the DeltaBuilder
API across the codebase for better consistency and maintainability.
2025-06-20 21:40:51 -05:00

43 lines
1008 B
TypeScript

import { createDelta } from '../src/core/delta-builder';
import {DeltaV1, DeltaV2} from "../src";
describe("Delta", () => {
it("can convert DeltaV1 to DeltaV2", () => {
const deltaV1 = createDelta('a', 'h')
.addPointer('color', 'red')
.addPointer('furniture', 'chair-1', 'color')
.buildV1();
const deltaV2 = DeltaV2.fromV1(deltaV1);
expect(deltaV2).toMatchObject({
...deltaV1,
pointers: {
color: 'red',
furniture: {'chair-1': 'color'}
}
});
});
it("can convert DeltaV2 to DeltaV1", () => {
const deltaV2 = createDelta('a', 'h')
.addPointer('color', 'red')
.addPointer('furniture', 'chair-1', 'color')
.buildV2();
const deltaV1 = deltaV2.toV1();
expect(deltaV1).toMatchObject({
...deltaV2,
pointers: [{
localContext: 'color',
target: 'red'
}, {
localContext: 'furniture',
target: 'chair-1',
targetContext: 'color'
}]
});
});
});