feat(editor): add isLocal flag in blockUpdated subject (#10799)
This commit is contained in:
@@ -267,20 +267,20 @@ test('on change', () => {
|
||||
const model = block.model as RootModel;
|
||||
|
||||
model.title = internalPrimitives.Text('abc');
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'title');
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'title', true);
|
||||
expect(model.title$.value.toDelta()).toEqual([{ insert: 'abc' }]);
|
||||
|
||||
onPropsUpdated.mockClear();
|
||||
|
||||
model.title.insert('d', 1);
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'title');
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'title', true);
|
||||
|
||||
expect(model.title$.value.toDelta()).toEqual([{ insert: 'adbc' }]);
|
||||
|
||||
onPropsUpdated.mockClear();
|
||||
|
||||
model.boxed.getValue()!.set('foo', 0);
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'boxed');
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'boxed', true);
|
||||
expect(model.boxed$.value.getValue()!.toJSON()).toEqual({
|
||||
foo: 0,
|
||||
});
|
||||
@@ -343,7 +343,7 @@ test('deep sync', () => {
|
||||
const map = new Y.Map();
|
||||
map.set('color', 'green');
|
||||
getColsMap().set('3', map);
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'cols');
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'cols', true);
|
||||
expect(onColsUpdated).toHaveBeenCalledWith({
|
||||
'1': { color: 'red' },
|
||||
'2': { color: 'blue' },
|
||||
@@ -356,7 +356,7 @@ test('deep sync', () => {
|
||||
onRowsUpdated.mockClear();
|
||||
|
||||
model.rows.push({ color: 'yellow' });
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'rows');
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'rows', true);
|
||||
expect(onRowsUpdated).toHaveBeenCalledWith([{ color: 'yellow' }]);
|
||||
expect(onPropsUpdated).toHaveBeenCalledTimes(1);
|
||||
expect(onRowsUpdated).toHaveBeenCalledTimes(1);
|
||||
@@ -367,7 +367,7 @@ test('deep sync', () => {
|
||||
const row1 = getRowsArr().get(0) as Y.Map<string>;
|
||||
row1.set('color', 'green');
|
||||
expect(onRowsUpdated).toHaveBeenCalledWith([{ color: 'green' }]);
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'rows');
|
||||
expect(onPropsUpdated).toHaveBeenCalledWith(expect.anything(), 'rows', true);
|
||||
expect(model.rows$.value).toEqual([{ color: 'green' }]);
|
||||
expect(onPropsUpdated).toHaveBeenCalledTimes(1);
|
||||
expect(onRowsUpdated).toHaveBeenCalledTimes(1);
|
||||
@@ -413,7 +413,7 @@ describe('flat', () => {
|
||||
});
|
||||
expect(onColUpdated).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'cols');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'cols', true);
|
||||
|
||||
model.props.cols.a.color = 'black';
|
||||
expect(yBlock.get('prop:cols.a.color')).toBe('black');
|
||||
@@ -432,7 +432,7 @@ describe('flat', () => {
|
||||
});
|
||||
expect(onColUpdated).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'cols');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'cols', true);
|
||||
|
||||
onChange.mockClear();
|
||||
onColUpdated.mockClear();
|
||||
@@ -442,7 +442,7 @@ describe('flat', () => {
|
||||
expect(model.props.cols$.value).toEqual({ a: {} });
|
||||
expect(onColUpdated).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'cols');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'cols', true);
|
||||
|
||||
model.props.cols = {
|
||||
a: { color: 'red' },
|
||||
@@ -462,7 +462,7 @@ describe('flat', () => {
|
||||
expect((yBlock.get('prop:title') as Y.Text).toJSON()).toBe('test');
|
||||
expect(model.props.title$.value.toDelta()).toEqual([{ insert: 'test' }]);
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'title');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'title', true);
|
||||
|
||||
onChange.mockClear();
|
||||
model.props.labels.push('test');
|
||||
@@ -470,18 +470,18 @@ describe('flat', () => {
|
||||
expect(getLabels().toJSON()).toEqual(['test']);
|
||||
expect(model.props.labels$.value).toEqual(['test']);
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'labels');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'labels', true);
|
||||
|
||||
onChange.mockClear();
|
||||
model.props.labels$.value = ['test2'];
|
||||
expect(getLabels().toJSON()).toEqual(['test2']);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'labels');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'labels', true);
|
||||
|
||||
onChange.mockClear();
|
||||
model.props.labels.splice(0, 1);
|
||||
expect(getLabels().toJSON()).toEqual([]);
|
||||
expect(model.props.labels$.value).toEqual([]);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'labels');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'labels', true);
|
||||
|
||||
model.props.textCols = {
|
||||
a: internalPrimitives.Text(),
|
||||
@@ -489,7 +489,7 @@ describe('flat', () => {
|
||||
onChange.mockClear();
|
||||
model.props.textCols.a.insert('test', 0);
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'textCols');
|
||||
expect(onChange).toHaveBeenCalledWith(expect.anything(), 'textCols', true);
|
||||
expect((yBlock.get('prop:textCols.a') as Y.Text).toJSON()).toBe('test');
|
||||
expect(model.props.textCols$.value.a.toDelta()).toEqual([
|
||||
{ insert: 'test' },
|
||||
|
||||
Reference in New Issue
Block a user