mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
fix 'minimongo - observe ordered with projection
This commit is contained in:
@@ -1859,7 +1859,7 @@ Tinytest.add('minimongo - fetch with projection, deep copy', test => {
|
||||
test.equal(filteredDoc.a.x, 43, 'projection returning deep copy - excluding');
|
||||
});
|
||||
|
||||
Tinytest.add('minimongo - observe ordered with projection', test => {
|
||||
Tinytest.addAsync('minimongo - observe ordered with projection', async test => {
|
||||
// These tests are copy-paste from "minimongo -observe ordered",
|
||||
// slightly modified to test projection
|
||||
const operations = [];
|
||||
@@ -1867,94 +1867,94 @@ Tinytest.add('minimongo - observe ordered with projection', test => {
|
||||
let handle;
|
||||
|
||||
const c = new LocalCollection();
|
||||
handle = c.find({}, {sort: {a: 1}, fields: { a: 1 }}).observe(cbs);
|
||||
handle = await c.find({}, {sort: {a: 1}, fields: { a: 1 }}).observe(cbs);
|
||||
test.isTrue(handle.collection === c);
|
||||
|
||||
c.insert({_id: 'foo', a: 1, b: 2});
|
||||
await c.insertAsync({_id: 'foo', a: 1, b: 2});
|
||||
test.equal(operations.shift(), ['added', {a: 1}, 0, null]);
|
||||
c.update({a: 1}, {$set: {a: 2, b: 1}});
|
||||
await c.updateAsync({a: 1}, {$set: {a: 2, b: 1}});
|
||||
test.equal(operations.shift(), ['changed', {a: 2}, 0, {a: 1}]);
|
||||
c.insert({_id: 'bar', a: 10, c: 33});
|
||||
await c.insertAsync({_id: 'bar', a: 10, c: 33});
|
||||
test.equal(operations.shift(), ['added', {a: 10}, 1, null]);
|
||||
c.update({}, {$inc: {a: 1}}, {multi: true});
|
||||
c.update({}, {$inc: {c: 1}}, {multi: true});
|
||||
await c.updateAsync({}, {$inc: {a: 1}}, {multi: true});
|
||||
await c.updateAsync({}, {$inc: {c: 1}}, {multi: true});
|
||||
test.equal(operations.shift(), ['changed', {a: 3}, 0, {a: 2}]);
|
||||
test.equal(operations.shift(), ['changed', {a: 11}, 1, {a: 10}]);
|
||||
c.update({a: 11}, {a: 1, b: 44});
|
||||
await c.updateAsync({a: 11}, {a: 1, b: 44});
|
||||
test.equal(operations.shift(), ['changed', {a: 1}, 1, {a: 11}]);
|
||||
test.equal(operations.shift(), ['moved', {a: 1}, 1, 0, 'foo']);
|
||||
c.remove({a: 2});
|
||||
await c.removeAsync({a: 2});
|
||||
test.equal(operations.shift(), undefined);
|
||||
c.remove({a: 3});
|
||||
await c.removeAsync({a: 3});
|
||||
test.equal(operations.shift(), ['removed', 'foo', 1, {a: 3}]);
|
||||
|
||||
// test stop
|
||||
handle.stop();
|
||||
const idA2 = Random.id();
|
||||
c.insert({_id: idA2, a: 2});
|
||||
await c.insertAsync({_id: idA2, a: 2});
|
||||
test.equal(operations.shift(), undefined);
|
||||
|
||||
const cursor = c.find({}, {fields: {a: 1, _id: 0}});
|
||||
test.throws(() => {
|
||||
cursor.observeChanges({added() {}});
|
||||
});
|
||||
test.throws(() => {
|
||||
cursor.observe({added() {}});
|
||||
await test.throwsAsync(async () => {
|
||||
await cursor.observe({added() {}});
|
||||
});
|
||||
|
||||
// test initial inserts (and backwards sort)
|
||||
handle = c.find({}, {sort: {a: -1}, fields: { a: 1 } }).observe(cbs);
|
||||
handle = await c.find({}, {sort: {a: -1}, fields: { a: 1 } }).observe(cbs);
|
||||
test.equal(operations.shift(), ['added', {a: 2}, 0, null]);
|
||||
test.equal(operations.shift(), ['added', {a: 1}, 1, null]);
|
||||
handle.stop();
|
||||
|
||||
// test _suppress_initial
|
||||
handle = c.find({}, {sort: {a: -1}, fields: { a: 1 }}).observe(Object.assign(cbs, {_suppress_initial: true}));
|
||||
handle = await c.find({}, {sort: {a: -1}, fields: { a: 1 }}).observe(Object.assign(cbs, {_suppress_initial: true}));
|
||||
test.equal(operations.shift(), undefined);
|
||||
c.insert({a: 100, b: { foo: 'bar' }});
|
||||
await c.insertAsync({a: 100, b: { foo: 'bar' }});
|
||||
test.equal(operations.shift(), ['added', {a: 100}, 0, idA2]);
|
||||
handle.stop();
|
||||
|
||||
// test skip and limit.
|
||||
c.remove({});
|
||||
handle = c.find({}, {sort: {a: 1}, skip: 1, limit: 2, fields: { blacklisted: 0 }}).observe(cbs);
|
||||
await c.removeAsync({});
|
||||
handle = await c.find({}, {sort: {a: 1}, skip: 1, limit: 2, fields: { blacklisted: 0 }}).observe(cbs);
|
||||
test.equal(operations.shift(), undefined);
|
||||
c.insert({a: 1, blacklisted: 1324});
|
||||
await c.insertAsync({a: 1, blacklisted: 1324});
|
||||
test.equal(operations.shift(), undefined);
|
||||
c.insert({_id: 'foo', a: 2, blacklisted: ['something']});
|
||||
await c.insertAsync({_id: 'foo', a: 2, blacklisted: ['something']});
|
||||
test.equal(operations.shift(), ['added', {a: 2}, 0, null]);
|
||||
c.insert({a: 3, blacklisted: { 2: 3 }});
|
||||
await c.insertAsync({a: 3, blacklisted: { 2: 3 }});
|
||||
test.equal(operations.shift(), ['added', {a: 3}, 1, null]);
|
||||
c.insert({a: 4, blacklisted: 6});
|
||||
await c.insertAsync({a: 4, blacklisted: 6});
|
||||
test.equal(operations.shift(), undefined);
|
||||
c.update({a: 1}, {a: 0, blacklisted: 4444});
|
||||
await c.updateAsync({a: 1}, {a: 0, blacklisted: 4444});
|
||||
test.equal(operations.shift(), undefined);
|
||||
c.update({a: 0}, {a: 5, blacklisted: 11111});
|
||||
await c.updateAsync({a: 0}, {a: 5, blacklisted: 11111});
|
||||
test.equal(operations.shift(), ['removed', 'foo', 0, {a: 2}]);
|
||||
test.equal(operations.shift(), ['added', {a: 4}, 1, null]);
|
||||
c.update({a: 3}, {a: 3.5, blacklisted: 333.4444});
|
||||
await c.updateAsync({a: 3}, {a: 3.5, blacklisted: 333.4444});
|
||||
test.equal(operations.shift(), ['changed', {a: 3.5}, 0, {a: 3}]);
|
||||
handle.stop();
|
||||
|
||||
// test _no_indices
|
||||
|
||||
c.remove({});
|
||||
handle = c.find({}, {sort: {a: 1}, fields: { a: 1 }}).observe(Object.assign(cbs, {_no_indices: true}));
|
||||
c.insert({_id: 'foo', a: 1, zoo: 'crazy'});
|
||||
await c.removeAsync({});
|
||||
handle = await c.find({}, {sort: {a: 1}, fields: { a: 1 }}).observe(Object.assign(cbs, {_no_indices: true}));
|
||||
await c.insertAsync({_id: 'foo', a: 1, zoo: 'crazy'});
|
||||
test.equal(operations.shift(), ['added', {a: 1}, -1, null]);
|
||||
c.update({a: 1}, {$set: {a: 2, foobar: 'player'}});
|
||||
await c.updateAsync({a: 1}, {$set: {a: 2, foobar: 'player'}});
|
||||
test.equal(operations.shift(), ['changed', {a: 2}, -1, {a: 1}]);
|
||||
c.insert({a: 10, b: 123.45});
|
||||
await c.insertAsync({a: 10, b: 123.45});
|
||||
test.equal(operations.shift(), ['added', {a: 10}, -1, null]);
|
||||
c.update({}, {$inc: {a: 1, b: 2}}, {multi: true});
|
||||
await c.updateAsync({}, {$inc: {a: 1, b: 2}}, {multi: true});
|
||||
test.equal(operations.shift(), ['changed', {a: 3}, -1, {a: 2}]);
|
||||
test.equal(operations.shift(), ['changed', {a: 11}, -1, {a: 10}]);
|
||||
c.update({a: 11, b: 125.45}, {a: 1, b: 444});
|
||||
await c.updateAsync({a: 11, b: 125.45}, {a: 1, b: 444});
|
||||
test.equal(operations.shift(), ['changed', {a: 1}, -1, {a: 11}]);
|
||||
test.equal(operations.shift(), ['moved', {a: 1}, -1, -1, 'foo']);
|
||||
c.remove({a: 2});
|
||||
await c.removeAsync({a: 2});
|
||||
test.equal(operations.shift(), undefined);
|
||||
c.remove({a: 3});
|
||||
await c.removeAsync({a: 3});
|
||||
test.equal(operations.shift(), ['removed', 'foo', -1, {a: 3}]);
|
||||
handle.stop();
|
||||
});
|
||||
|
||||
@@ -3441,7 +3441,7 @@ async function bundle({
|
||||
if (hasCachedBundle) {
|
||||
// If we already have a cached bundle, just recreate the new targets.
|
||||
// XXX This might make the contents of "star.json" out of date.
|
||||
for (const target of targets) {
|
||||
for (const target of Object.values(targets)) {
|
||||
await writeClientTarget(target);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user