Skip to content
This repository has been archived by the owner on May 19, 2019. It is now read-only.

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Artemyev committed Jan 30, 2016
1 parent bcb7fac commit 2ce0ca4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions lib/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ export class Collection extends EventEmitter {
doc = this.create(doc);
doc._id = doc._id || randomId.value;

return this._writeQueue.add(() =>
return this._writeQueue.add(() => {
this.emit('beforeInsert', doc, randomId);
if (!options.quiet) {
this.emit('sync:insert', doc, randomId);
}
this.delegate.insert(doc, options).then((docId) => {
return this.delegate.insert(doc, options).then((docId) => {
this.emit('insert', doc, null, randomId);
return docId;
});
);
});
}

/**
Expand All @@ -174,16 +174,16 @@ export class Collection extends EventEmitter {
* @return {Promise}
*/
remove(query, options = {}) {
return this._writeQueue.add(() =>
return this._writeQueue.add(() => {
this.emit('beforeRemove', query, options);
if (!options.quiet) {
this.emit('sync:remove', query, options);
}
this.delegate.remove(query, options).then((removedDocs) => {
return this.delegate.remove(query, options).then((removedDocs) => {
_each(removedDocs, d => this.emit('remove', null, d));
return removedDocs;
});
);
});
}

/**
Expand All @@ -196,18 +196,18 @@ export class Collection extends EventEmitter {
* @return {Promise}
*/
update(query, modifier, options = {}) {
return this._writeQueue.add(() =>
return this._writeQueue.add(() => {
this.emit('beforeUpdate', query, modifier, options);
if (!options.quiet) {
this.emit('sync:update', query, modifier, options);
}
this.delegate.update(query, modifier, options).then(res => {
return this.delegate.update(query, modifier, options).then(res => {
_each(res.updated, (d, i) => {
this.emit('update', d, res.original[i]);
});
return res;
});
);
});
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/PromiseQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export default class PromiseQueue {
* Pause queue processing
*/
pause() {
this.pause = true;
this._paused = true;
}

/**
* Resume queue processing
*/
unpause() {
this.pause = false;
this._paused = false;
this._dequeue();
}

Expand Down Expand Up @@ -66,7 +66,7 @@ export default class PromiseQueue {
* @return {Boolean}
*/
_dequeue() {
if (this.pause || this.pendingPromises >= this.maxPendingPromises) {
if (this._paused || this.pendingPromises >= this.maxPendingPromises) {
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions test/both/Collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Collection', () => {
Collection.defaultStorageManager().should.be.equal(NewStorageManager);
});
it('should upgrade all collections uses defaults', function () {
const defColl = new Collection();
const defColl = new Collection('test', {upgradeDefaults: true});
defColl.storage.should.be.instanceof(Collection.defaultStorageManager());
class NewStorageManager {}
Collection.defaultStorageManager(NewStorageManager);
Expand All @@ -82,7 +82,7 @@ describe('Collection', () => {
Collection.defaultIdGenerator().should.be.equal(new_id_generator);
});
it('should upgrade all collections uses defaults', function () {
const defColl = new Collection();
const defColl = new Collection('test', {upgradeDefaults: true});
defColl.idGenerator.should.be.equal(Collection.defaultIdGenerator());
function new_id_generator() {}
Collection.defaultIdGenerator(new_id_generator);
Expand All @@ -97,7 +97,7 @@ describe('Collection', () => {
Collection.defaultDelegate().should.be.equal(NewDelegate);
});
it('should upgrade all collections uses defaults', function () {
const defColl = new Collection();
const defColl = new Collection('test', {upgradeDefaults: true});
defColl.delegate.should.be.instanceof(Collection.defaultDelegate());
class NewDelegate {}
Collection.defaultDelegate(NewDelegate);
Expand All @@ -112,7 +112,7 @@ describe('Collection', () => {
Collection.defaultIndexManager().should.be.equal(NewIndexManager);
});
it('should upgrade all collections uses defaults', function () {
const defColl = new Collection();
const defColl = new Collection('test', {upgradeDefaults: true});
defColl.indexManager.should.be.instanceof(Collection.defaultIndexManager());
class NewIndexManager {}
Collection.defaultIndexManager(NewIndexManager);
Expand Down

0 comments on commit 2ce0ca4

Please sign in to comment.