it(`set / get / remove`, () => Promise.all([
   assert.isFulfilled(store.add(item1_80)),
   assert.isFulfilled(store.add(item2_80)),
   assert.isFulfilled(store.add(item3_80)),
   assert.eventually.deepEqual(store.get(item1_80), item1_80.url),
   assert.eventually.deepEqual(store.get(item2_80), item2_80.url),
   assert.eventually.deepEqual(store.get(item3_80), item3_80.url),
   store.remove(item2_80),
   store.remove(item3_80),
   assert.isRejected(store.get(item3_80)),
   assert.isRejected(store.get(item2_80)),
   assert.isFulfilled(store.add(item1_40)),
   assert.isFulfilled(store.add(item1_50)),
   assert.isFulfilled(store.add(item1_110)),
   assert.isFulfilled(store.add(item1_192)),
   assert.isFulfilled(store.add(item1_640)),
   assert.isFulfilled(store.add(item1_1600)),
   store.remove({uuid: `88888888-4444-4444-4444-aaaaaaaaaaa0`}),
   assert.isRejected(store.get(item1_40)),
   assert.isRejected(store.get(item1_50)),
   assert.isRejected(store.get(item1_80)),
   assert.isRejected(store.get(item1_110)),
   assert.isRejected(store.get(item1_192)),
   assert.isRejected(store.get(item1_640)),
   assert.isRejected(store.get(item1_1600))
 ]));
Example #2
0
 it(`does not add conditional properties`, () => assert.isFulfilled(spark.internal.mercury._prepareUrl())
   .then((wsUrl) => {
     assert.notMatch(wsUrl, /mercuryRegistrationStatus/);
     assert.notMatch(wsUrl, /mercuryRegistrationStatus/);
     assert.notMatch(wsUrl, /isRegistrationRefreshEnabled/);
     assert.notMatch(wsUrl, /multipleConnections/);
   }));
Example #3
0
          .then((res) => {
            const createdMeeting = res.body;
            return assert.isFulfilled(mercuryPromise)
              .then((calendarMeetingExternal) => {
                assert.equal(createdMeeting.meeting.meetingSeriesId, calendarMeetingExternal.seriesId);
                assert.equal(createdMeeting.userUUID, calendarMeetingExternal.organizer);
                assert.equal(createdMeeting.meeting.startDate, calendarMeetingExternal.start);
                assert.equal(Math.round((new Date(createdMeeting.meeting.endDate).getTime() - new Date(createdMeeting.meeting.startDate).getTime()) / 60000), calendarMeetingExternal.durationMinutes);

                // Validate decryption of subject, location and agenda
                assert.isDefined(calendarMeetingExternal.encryptedSubject);
                assert.equal(meetingParams.title, calendarMeetingExternal.encryptedSubject);
                assert.isDefined(calendarMeetingExternal.encryptedLocation);
                assert.equal(meetingParams.location, calendarMeetingExternal.encryptedLocation);
                assert.isDefined(calendarMeetingExternal.encryptedNotes);
                assert.equal(meetingParams.body, calendarMeetingExternal.encryptedNotes);
                assert.isDefined(calendarMeetingExternal.encryptedParticipants);
                const encryptedParticipant1 = calendarMeetingExternal.encryptedParticipants
                  .find((participant) => participant.id === meetingParams.participants.participant1.id);
                const encryptedParticipant2 = calendarMeetingExternal.encryptedParticipants
                  .find((participant) => participant.id === meetingParams.participants.participant2.id);
                assert.equal(meetingParams.participants.participant1.emailAddress, encryptedParticipant1.encryptedEmailAddress);
                assert.equal(meetingParams.participants.participant1.name, encryptedParticipant1.encryptedName);
                assert.equal(meetingParams.participants.participant2.emailAddress, encryptedParticipant2.encryptedEmailAddress);
                assert.equal(meetingParams.participants.participant2.name, encryptedParticipant2.encryptedName);
              });
          });
Example #4
0
      it(`emits Error-safe events`, () => {
        mercury.on(`break`, () => {
          throw new Error();
        });

        return assert.isFulfilled(Promise.resolve(mercury._emit(`break`)));
      });
Example #5
0
 .then((res) => {
   assert.isTrue(res.verificationEmailTriggered);
   assert.property(res, `verifyEmailURL`);
   const query = url.parse(res.verifyEmailURL).query;
   const token = querystring.parse(query).t;
   return assert.isFulfilled(unauthSpark.internal.user.activate({verificationToken: token}));
 })
Example #6
0
 .then(() => {
   assert.isTrue(mercury.connected, `Mercury is connected`);
   assert.isFalse(mercury.connecting, `Mercury is not connecting`);
   const promise = mercury.connect();
   assert.isTrue(mercury.connected, `Mercury is connected`);
   assert.isFalse(mercury.connecting, `Mercury is not connecting`);
   return assert.isFulfilled(promise);
 }));
Example #7
0
 it(`is a noop for outbound calls`, () => handleErrorEvent(spock.spark.phone.dial(mccoy.id), (call) => {
   sinon.spy(call, `_join`);
   return assert.isFulfilled(call.answer())
     .then(() => {
       // We called _join to create the call
       assert.calledWith(call._join, `create`);
       // But we did not call _join when we invoked answer()
       assert.neverCalledWith(call._join, `join`);
     });
 }));
Example #8
0
 it(`resolves upon successful authorization`, () => {
   const s = new Socket();
   const promise = s.open(`ws://example.com`, mockoptions);
   mockWebSocket.readyState = 1;
   mockWebSocket.emit(`open`);
   mockWebSocket.emit(`message`, {
     data: JSON.stringify({
       id: JSON.parse(mockWebSocket.send.args[1][0]).id,
       type: `pong`
     })
   });
   return assert.isFulfilled(promise)
     .then(() => s.close());
 });
Example #9
0
 it(`resolves upon receiving registration status`, () => {
   const s = new Socket();
   const promise = s.open(`ws://example.com`, mockoptions);
   mockWebSocket.readyState = 1;
   mockWebSocket.emit(`open`);
   mockWebSocket.emit(`message`, {
     data: JSON.stringify({
       data: {
         eventType: `mercury.registration_status`
       }
     })
   });
   return assert.isFulfilled(promise)
     .then(() => s.close());
 });
Example #10
0
 it(`requests text-mode WebSockets`, () => assert.isFulfilled(spark.internal.mercury._prepareUrl())
   .then((wsUrl) => assert.match(wsUrl, /outboundWireFormat=text/)));
Example #11
0
 .then(() => {
   // eslint-disable-next-line camelcase
   spark.credentials.supertoken.access_token = `fake token`;
   return assert.isFulfilled(spark.internal.mercury.connect());
 })
Example #12
0
 .then(() => assert.isFulfilled(c.answer()))
Example #13
0
 it(`requests the buffer state message`, () => assert.isFulfilled(spark.internal.mercury._prepareUrl())
   .then((wsUrl) => assert.match(wsUrl, /bufferStates=true/)));
Example #14
0
 it(`requests the registration banner`, () => assert.isFulfilled(spark.internal.mercury._prepareUrl())
   .then((wsUrl) => assert.match(wsUrl, /mercuryRegistrationStatus=true/)));
Example #15
0
 it(`requests shared socket support`, () => assert.isFulfilled(spark.internal.mercury._prepareUrl())
   .then((wsUrl) => assert.match(wsUrl, /isRegistrationRefreshEnabled=true/)));
Example #16
0
 it(`accepts a reason`, () => assert.isFulfilled(socket.close({
   code: 3001,
   reason: `Custom Normal`
 }))
   .then(() => assert.calledWith(mockWebSocket.close, 3001, `Custom Normal`)));
Example #17
0
 .then(() => {
   mockWebSocket.readyState = 1;
   return assert.isFulfilled(socket.send(`test1`));
 });
Example #18
0
 it(`only accepts valid close codes`, () => Promise.all([
   assert.isRejected(socket.close({code: 1001}), /`options.code` must be 1000 or between 3000 and 4999 \(inclusive\)/),
   assert.isFulfilled(socket.close({code: 1000}))
 ]));
Example #19
0
 .then(() => {
   assert.called(spark.credentials.refresh);
   assert.notCalled(spark.internal.device.refresh);
   clock.tick(1000);
   return assert.isFulfilled(promise);
 });
Example #20
0
 it(`connects to mercury`, () => assert.isFulfilled(spark.internal.mercury.connect()));
Example #21
0
 it(`indicates multiple connections may be coming from this user`, () => assert.isFulfilled(spark.internal.mercury._prepareUrl())
   .then((wsUrl) => assert.match(wsUrl, /multipleConnections/)));
Example #22
0
 it(`does not request the buffer state message`, () => assert.isFulfilled(spark.internal.mercury._prepareUrl())
   .then((wsUrl) => {
     assert.match(wsUrl, /mercuryRegistrationStatus=true/);
     assert.notMatch(wsUrl, /bufferStates/);
   }));
Example #23
0
 it(`is a noop when already registered`, () => assert.isFulfilled(spock.spark.phone.register()));
Example #24
0
 .then(() => {
   assert.calledThrice(Socket.prototype.open);
   clock.tick(4 * mercury.config.backoffTimeReset);
   return assert.isFulfilled(promise);
 })