fix remaining y-map tests
This commit is contained in:
parent
da9836fe59
commit
95ec2a435a
@ -145,21 +145,6 @@ export const testGetAndSetAndDeleteOfMapPropertyWithThreeConflicts = tc => {
|
|||||||
compare(users)
|
compare(users)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testObservepathProperties = tc => {
|
|
||||||
const { users, map0, map1, map2, testConnector } = init(tc, { users: 3 })
|
|
||||||
let map
|
|
||||||
map0.observePath(['map'], map => {
|
|
||||||
if (map != null) {
|
|
||||||
map.set('yay', 4)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
map1.set('map', new Y.Map())
|
|
||||||
testConnector.flushAllMessages()
|
|
||||||
map = map2.get('map')
|
|
||||||
t.compare(map.get('yay'), 4)
|
|
||||||
compare(users)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const testObserveDeepProperties = tc => {
|
export const testObserveDeepProperties = tc => {
|
||||||
const { testConnector, users, map1, map2, map3 } = init(tc, { users: 4 })
|
const { testConnector, users, map1, map2, map3 } = init(tc, { users: 4 })
|
||||||
const _map1 = map1.set('map', new Y.Map())
|
const _map1 = map1.set('map', new Y.Map())
|
||||||
@ -212,7 +197,11 @@ export const testObserversUsingObservedeep = tc => {
|
|||||||
// TODO: Test events in Y.Map
|
// TODO: Test events in Y.Map
|
||||||
const compareEvent = (t, is, should) => {
|
const compareEvent = (t, is, should) => {
|
||||||
for (var key in should) {
|
for (var key in should) {
|
||||||
t.assert(should[key] === is[key])
|
if (should[key].constructor === Set) {
|
||||||
|
t.compare(Array.from(should[key]), Array.from(is[key]))
|
||||||
|
} else {
|
||||||
|
t.assert(should[key] === is[key])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,30 +213,22 @@ export const testThrowsAddAndUpdateAndDeleteEvents = tc => {
|
|||||||
})
|
})
|
||||||
map0.set('stuff', 4)
|
map0.set('stuff', 4)
|
||||||
compareEvent(t, event, {
|
compareEvent(t, event, {
|
||||||
type: 'add',
|
target: map0,
|
||||||
object: map0,
|
keysChanged: new Set(['stuff'])
|
||||||
name: 'stuff'
|
|
||||||
})
|
})
|
||||||
// update, oldValue is in contents
|
// update, oldValue is in contents
|
||||||
map0.set('stuff', new Y.Array())
|
map0.set('stuff', new Y.Array())
|
||||||
compareEvent(t, event, {
|
compareEvent(t, event, {
|
||||||
type: 'update',
|
target: map0,
|
||||||
object: map0,
|
keysChanged: new Set(['stuff'])
|
||||||
name: 'stuff',
|
|
||||||
oldValue: 4
|
|
||||||
})
|
})
|
||||||
let replacedArray = map0.get('stuff')
|
|
||||||
// update, oldValue is in opContents
|
// update, oldValue is in opContents
|
||||||
map0.set('stuff', 5)
|
map0.set('stuff', 5)
|
||||||
let array = event.oldValue
|
|
||||||
t.compare(array._model, replacedArray._model)
|
|
||||||
// delete
|
// delete
|
||||||
map0.delete('stuff')
|
map0.delete('stuff')
|
||||||
compareEvent(t, event, {
|
compareEvent(t, event, {
|
||||||
type: 'delete',
|
keysChanged: new Set(['stuff']),
|
||||||
name: 'stuff',
|
target: map0
|
||||||
object: map0,
|
|
||||||
oldValue: 5
|
|
||||||
})
|
})
|
||||||
compare(users)
|
compare(users)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user