Skip to content

Instantly share code, notes, and snippets.

@nc
Created November 26, 2021 17:49
Show Gist options
  • Save nc/f1ab3957350434f7387671b0b4b9ae5e to your computer and use it in GitHub Desktop.
Save nc/f1ab3957350434f7387671b0b4b9ae5e to your computer and use it in GitHub Desktop.
Failing test case for #14
import * as Y from 'yjs';
import { proxy } from 'valtio/vanilla';
import { bindProxyAndYMap } from '../src/index';
describe('issue #14', () => {
it('nested map direct set', async () => {
const doc = new Y.Doc();
const p = proxy({ items: { item1: { color: 'blue' } } });
const m = doc.getMap('map');
bindProxyAndYMap(p, m);
p.items.item1.color = 'red';
await Promise.resolve();
expect(m.get('items').get('item1').get('color')).toStrictEqual('red');
});
it('nested map 1 level outer set', async () => {
const doc = new Y.Doc();
const p = proxy({ items: { item1: { color: 'blue' } } });
const m = doc.getMap('map');
bindProxyAndYMap(p, m);
p.items.item1 = { color: 'red' };
await Promise.resolve();
expect(m.get('items').get('item1').get('color')).toStrictEqual('red');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment