MCPcopy Index your code
hub / github.com/share/sharedb / testBulkSnapshotSpecificError

Function testBulkSnapshotSpecificError

test/client/subscribe.js:221–300  ·  view source on GitHub ↗
(label, fns)

Source from the content-addressed store, hash-verified

219 });
220
221 function testBulkSnapshotSpecificError(label, fns) {
222 var rejectSnapshot = fns.rejectSnapshot;
223 var verifyClientError = fns.verifyClientError;
224 it(method + ' bulk with readSnapshots rejectSnapshotRead ' + label, function(done) {
225 var backend = this.backend;
226 var connection = backend.connect();
227 var connection2 = backend.connect();
228 async.parallel([
229 function(cb) {
230 connection.get('dogs', 'fido').create({age: 3}, cb);
231 },
232 function(cb) {
233 connection.get('dogs', 'spot').create({age: 5}, cb);
234 }
235 ], function(err) {
236 if (err) return done(err);
237
238 backend.use('readSnapshots', function(context, cb) {
239 expect(context.snapshots).to.be.an('array').of.length(2);
240 expect(context.snapshots[0]).to.have.property('id', 'fido');
241 rejectSnapshot(context, context.snapshots[0]);
242 cb();
243 });
244
245 var fido = connection2.get('dogs', 'fido');
246 var spot = connection2.get('dogs', 'spot');
247 connection2.startBulk();
248 async.parallel([
249 function(cb) {
250 fido[method](function(err) {
251 verifyClientError(err);
252 cb();
253 });
254 },
255 function(cb) {
256 spot[method](cb);
257 }
258 ], function(err) {
259 if (err) return done(err);
260 // An error for 'fido' means the data shouldn't get loaded.
261 expect(fido.data).eql(undefined);
262 // Data for 'spot' should still be loaded.
263 expect(spot.data).eql({age: 5});
264
265 // For subscribe, also test that further remote ops will only get sent for the doc
266 // without the error.
267 if (method !== 'subscribe') {
268 return done();
269 }
270 // Add listeners on connection2 for those operations.
271 fido.on('before op', function(op) {
272 done(new Error('fido on connection2 should not have received any ops, got:' +
273 JSON.stringify(op)));
274 });
275
276 var fido1 = connection.get('dogs', 'fido');
277 var spot1 = connection.get('dogs', 'spot');
278

Callers 1

subscribe.jsFile · 0.85

Calls 1

cbFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…