Skip to content

Commit

Permalink
Merge pull request #193 from jeffbocala/fixes-push-updates
Browse files Browse the repository at this point in the history
Wait for APNs response before resolving
  • Loading branch information
tinovyatkin committed Aug 22, 2019
2 parents e03d4ad + de2e0e6 commit 9478c0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 6 additions & 8 deletions __tests__/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ describe('Template', () => {
template.pushUpdates(
'0e40d22a36e101a59ab296d9e6021df3ee1dcf95e29e8ab432213b12ba522dbb',
),
).resolves.toBeUndefined();
// if (template.apn) template.apn.destroy();
// expect(res).toEqual(
// expect.objectContaining({
// ':status': 200,
// 'apns-id': expect.any(String),
// }),
// );
).resolves.toEqual(
expect.objectContaining({
':status': 200,
'apns-id': expect.any(String),
}),
);
}, 7000);
});
5 changes: 4 additions & 1 deletion src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,11 @@ export class Template extends PassBase {
// Error handling
req.once('error', reject);

// Wait for response before resolving
req.once('response', resolve);

// Post payload (always empty in our case)
req.end('{}', resolve);
req.end('{}');
});
}

Expand Down

0 comments on commit 9478c0e

Please sign in to comment.