Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f25f53

Browse files
committed
feat(subscriptions): added test for multiple subscribers for the same subscription
1 parent 54ca988 commit 5f25f53

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/subscription/__tests__/subscribe-test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,44 @@ describe('Subscribe', () => {
192192
'A subscription operation must contain exactly one root field.');
193193
});
194194

195+
it('produces payload for multiple subscribe in same subscription',
196+
async () => {
197+
const pubsub = new EventEmitter();
198+
const { sendImportantEmail, subscription } = createSubscription(pubsub);
199+
const second = createSubscription(pubsub);
200+
201+
const payload1 = subscription.next();
202+
const payload2 = second.subscription.next();
203+
204+
expect(sendImportantEmail({
205+
206+
subject: 'Alright',
207+
message: 'Tests are good',
208+
unread: true,
209+
})).to.equal(true);
210+
211+
const expectedPayload = {
212+
done: false,
213+
value: {
214+
data: {
215+
importantEmail: {
216+
email: {
217+
218+
subject: 'Alright',
219+
},
220+
inbox: {
221+
unread: 1,
222+
total: 2,
223+
},
224+
},
225+
},
226+
},
227+
};
228+
229+
expect(await payload1).to.deep.equal(expectedPayload);
230+
expect(await payload2).to.deep.equal(expectedPayload);
231+
});
232+
195233
it('produces a payload per subscription event', async () => {
196234
const pubsub = new EventEmitter();
197235
const { sendImportantEmail, subscription } = createSubscription(pubsub);

0 commit comments

Comments
 (0)