Repository: parse-community/Parse-SDK-JS
Pull request #640 (2018-08-14 12:42:53)

Fixes issue #639

codecov[bot]: # [Codecov](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640?src=pr&el=h1) Report
> Merging [#640](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640?src=pr&el=desc) into [master](https://codecov.io/gh/parse-community/Parse-SDK-JS/commit/db59b63bcc37abf914a8b4fb261354e8aa6cdcc4?src=pr&el=desc) will **increase** coverage by `0.12%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640/graphs/tree.svg?src=pr&token=8nCENM0QHj&width=650&height=150)](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #640      +/-   ##
==========================================
+ Coverage   85.55%   85.68%   +0.12%     
==========================================
  Files          48       48              
  Lines        3877     3876       -1     
  Branches      877      877              
==========================================
+ Hits         3317     3321       +4     
+ Misses        560      555       -5
```


| [Impacted Files](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/LiveQuerySubscription.js](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640/diff?src=pr&el=tree#diff-c3JjL0xpdmVRdWVyeVN1YnNjcmlwdGlvbi5qcw==) | `100% <ø> (+50%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640?src=pr&el=footer). Last update [db59b63...a8fe239](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/640?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/LiveQuerySubscription.js b/src/LiveQuerySubscription.js
index fa3c5a8..3593bc7 100644
--- a/src/LiveQuerySubscription.js
+++ b/src/LiveQuerySubscription.js
@@ -106,7 +106,6 @@ class Subscription extends EventEmitter {
     return CoreManager.getLiveQueryController().getDefaultLiveQueryClient().then((liveQueryClient) => {
       liveQueryClient.unsubscribe(this);
       this.emit('close');
-      this.resolve();
     });
   }
 }


Test patch:
diff --git a/src/__tests__/ParseLiveQuery-test.js b/src/__tests__/ParseLiveQuery-test.js
index 6ec9470..4979625 100644
--- a/src/__tests__/ParseLiveQuery-test.js
+++ b/src/__tests__/ParseLiveQuery-test.js
@@ -20,6 +20,7 @@ jest.dontMock('../promiseUtils');
 require('../ParseLiveQuery');
 const CoreManager = require('../CoreManager');
 const ParseQuery = require('../ParseQuery').default;
+const LiveQuerySubscription = require('../LiveQuerySubscription').default;
 
 describe('ParseLiveQuery', () => {
   beforeEach(() => {
@@ -182,4 +183,11 @@ describe('ParseLiveQuery', () => {
     });
 
   });
+
+  it('should not throw on usubscribe', (done) => {
+    const query = new ParseQuery("ObjectType");
+    query.equalTo("test", "value");
+    const subscription = new LiveQuerySubscription('0', query, 'token');
+    subscription.unsubscribe().then(done).catch(done.fail);
+  });
 });