Skip to content

Commit

Permalink
✅ Move projections test inside getQuery check
Browse files Browse the repository at this point in the history
The `getQuery` test option is optional, but the projections tests try
to run regardless of whether it's set.

This change moves it inside the guard for this option.
  • Loading branch information
alecgibson committed Jun 7, 2024
1 parent 7abe650 commit 97dc188
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
38 changes: 38 additions & 0 deletions test/client/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,43 @@ module.exports = function(options) {
});
});
});

it('snapshot fetch from query does not advance version of doc with pending ops', function(done) {
var backend = this.backend;
backend.connect(null, null, function(connection1) {
backend.connect(null, null, function(connection2) {
var doc = connection1.get('dogs', 'fido');
var doc2 = connection2.get('dogs', 'fido');
doc.create({name: 'kido'}, function(err) {
if (err) return done(err);
doc2.fetch(function(err) {
if (err) return done(err);
doc2.submitOp({p: ['name', 0], si: 'f'}, function(err) {
if (err) return done(err);
expect(doc2.data).eql({name: 'fkido'});
doc.connection.createFetchQuery('dogs', {}, null, function(err) {
if (err) return done(err);
doc.resume();
});
});
});
});
process.nextTick(function() {
doc.pause();
doc.submitOp({p: ['name', 0], sd: 'k'}, function(err) {
if (err) return done(err);
doc.pause();
doc2.fetch(function(err) {
if (err) return done(err);
expect(doc2.version).equal(3);
expect(doc2.data).eql({name: 'fido'});
done();
});
});
doc.del();
});
});
});
});
});
};
38 changes: 0 additions & 38 deletions test/client/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,44 +898,6 @@ module.exports = function() {
});
});

it('snapshot fetch from query does not advance version of doc with pending ops', function(done) {
var backend = this.backend;
backend.connect(null, null, function(connection1) {
backend.connect(null, null, function(connection2) {
var doc = connection1.get('dogs', 'fido');
var doc2 = connection2.get('dogs', 'fido');
doc.create({name: 'kido'}, function(err) {
if (err) return done(err);
doc2.fetch(function(err) {
if (err) return done(err);
doc2.submitOp({p: ['name', 0], si: 'f'}, function(err) {
if (err) return done(err);
expect(doc2.data).eql({name: 'fkido'});
doc.connection.createFetchQuery('dogs', {}, null, function(err) {
if (err) return done(err);
doc.resume();
});
});
});
});
process.nextTick(function() {
doc.pause();
doc.submitOp({p: ['name', 0], sd: 'k'}, function(err) {
if (err) return done(err);
doc.pause();
doc2.fetch(function(err) {
if (err) return done(err);
expect(doc2.version).equal(3);
expect(doc2.data).eql({name: 'fido'});
done();
});
});
doc.del();
});
});
});
});

it('passing an error in submit middleware rejects a create and calls back with the erorr', function(done) {
this.backend.use('submit', function(request, next) {
next({message: 'Custom error'});
Expand Down
2 changes: 1 addition & 1 deletion test/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ module.exports = function(options) {
if (options.getQuery) {
require('./client/query-subscribe')({getQuery: options.getQuery});
require('./client/query')({getQuery: options.getQuery});
require('./client/projections')({getQuery: options.getQuery});
}

require('./client/projections')({getQuery: options.getQuery});
require('./client/submit')();
require('./client/submit-json1')();
require('./client/subscribe')();
Expand Down

0 comments on commit 97dc188

Please sign in to comment.