- Renamed Lossless class to Hyperview for clarity - Renamed Lossy class to View for simplicity - Updated all imports and references throughout the codebase - Updated documentation to reflect new terminology - Fixed test files to use new class names - Added proper exports in index files
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import Debug from "debug";
|
|
import { createDelta } from '@src/core/delta-builder';
|
|
import { Hyperview, RhizomeNode } from '@src';
|
|
import { TimestampResolver } from '@src/views/resolvers/timestamp-resolvers';
|
|
const debug = Debug('rz:test:last-write-wins');
|
|
|
|
// This was initially written to test a LastWriteWins resolver, but that has been
|
|
// superceded by the TimestampResolver.
|
|
|
|
describe('Last write wins', () => {
|
|
|
|
describe('given that two separate writes occur', () => {
|
|
const node = new RhizomeNode();
|
|
const hyperview = new Hyperview(node);
|
|
|
|
const view = new TimestampResolver(hyperview);
|
|
|
|
beforeAll(() => {
|
|
hyperview.ingestDelta(createDelta('a', 'h')
|
|
.setProperty('broccoli', 'want', 95, 'vegetable')
|
|
.buildV1()
|
|
);
|
|
|
|
hyperview.ingestDelta(createDelta('a', 'h')
|
|
.setProperty('broccoli', 'want', 90, 'vegetable')
|
|
.buildV1()
|
|
);
|
|
});
|
|
|
|
test('our resolver should return the most recently written value', () => {
|
|
const result = view.resolve(["broccoli"]);
|
|
debug('result', result);
|
|
expect(result).toMatchObject({
|
|
broccoli: {
|
|
id: "broccoli",
|
|
properties: {
|
|
want: 90
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|