Skip to content

Commit

Permalink
MLIBZ-2131 Remove the restriction for CacheStore.group() and CacheSto…
Browse files Browse the repository at this point in the history
…re.count(), that returned an error when there are entities to push. Change tests accordingly.
  • Loading branch information
gprodanov committed Mar 23, 2018
1 parent bb49460 commit 26f9e86
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 54 deletions.
43 changes: 0 additions & 43 deletions src/core/datastore/cachestore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,28 +397,6 @@ describe('CacheStore', () => {
});
});

it('should throw an error if there are entities to sync', (done) => {
const entity = { _id: randomString() };
const syncStore = new SyncStore(collection);
syncStore.save(entity)
.then(() => {
const aggregation = new Aggregation();
const store = new CacheStore(collection);
store.group(aggregation)
.subscribe(null, (error) => {
try {
expect(error).toBeA(KinveyError);
expect(error.message).toInclude(pendingPushEntitiesErrMsg);
done();
} catch (e) {
done(e);
}
}, () => {
done(new Error('This test should fail.'));
});
});
});

it('should return the count of all unique properties on the collection', (done) => {
const entity1 = { _id: randomString(), title: randomString() };
const entity2 = { _id: randomString(), title: randomString() };
Expand Down Expand Up @@ -489,27 +467,6 @@ describe('CacheStore', () => {
});
});

it('should throw an error if there are entities to sync', (done) => {
const entity = { _id: randomString() };
const syncStore = new SyncStore(collection);
syncStore.save(entity)
.then(() => {
const store = new CacheStore(collection);
store.count()
.subscribe(null, (error) => {
try {
expect(error).toBeA(KinveyError);
expect(error.message).toInclude(pendingPushEntitiesErrMsg);
done();
} catch (e) {
done(e);
}
}, () => {
done(new Error('This test should fail.'));
});
});
});

it('should return the count for the collection', (done) => {
const entity1 = { _id: randomString() };
const entity2 = { _id: randomString() };
Expand Down
10 changes: 3 additions & 7 deletions src/core/datastore/processors/cache-offline-data-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,9 @@ export class CacheOfflineDataProcessor extends OfflineDataProcessor {
return super._processCount(collection, query, options)
.then((offlineCount) => {
observer.next(offlineCount);
return this._ensureCountBeforeRead(collection, 'count entities', query);
return this._networkRepository.count(collection, query, options);
})
.then(() => this._networkRepository.count(collection, query, options))
.then((networkCount) => {
observer.next(networkCount);
});
.then(networkCount => observer.next(networkCount));
});
}

Expand All @@ -143,9 +140,8 @@ export class CacheOfflineDataProcessor extends OfflineDataProcessor {
.catch(() => []) // backwards compatibility
.then((offlineResult) => {
observer.next(offlineResult);
return this._ensureCountBeforeRead(collection, 'group entities');
return this._networkRepository.group(collection, aggregationQuery, options);
})
.then(() => this._networkRepository.group(collection, aggregationQuery, options))
.then(networkResult => observer.next(networkResult));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ describe('CacheOfflineDataProcessor', () => {
expect(result).toBeA(KinveyObservable);
});

addSyncQueueTests();

it('should call OfflineRepo.count()', () => {
return dataProcessor.process(operation, options).toPromise()
.then(() => {
Expand Down Expand Up @@ -242,8 +240,6 @@ describe('CacheOfflineDataProcessor', () => {
});
});

addSyncQueueTests();

it('should call NetworkRepo.group()', () => {
return dataProcessor.process(operation, options).toPromise()
.then(() => {
Expand Down

0 comments on commit 26f9e86

Please sign in to comment.