A test suite for use with any moped-sync-store.
npm install moped-sync-store-tests
'use strict';
var test = require('../../moped-sync-store-tests');
var MemoryStore = require('../');
test(new MemoryStore()).done(function () {
console.log('Tests passed');
});
A sync store is an object with the following methods:
- getItem(collection, itemId)
- getInitial(filter)
- writeChanges(changes)
- getChanges(id, filter)
This method returns a promise for the current value of an item. This is useful for filtering updates.
This gets the initial state for a client. It should be an object with two properties:
- state
- next
next
is the Id to give to getChanges
in order to get changes since this state. state
is the current state of all objects allowed by filter
. It is an object with a property for each collection, containg an array of values that match the corresponding filter.
Writes an array of changes.
Gets all the changes since id
that match filter. Returns {changes: [array of changes], next: [Id to give to next getChanges call]}
MIT