Example #1
0
 it(`emits download progress events for non-encrypted files`, () => {
   const spy = sinon.spy();
   return spark.internal.conversation.download({url: makeLocalUrl(`/sample-image-small-one.png`)})
     .on(`progress`, spy)
     .then((f) => assert.eventually.isTrue(fh.isMatchingFile(f, sampleImageSmallOnePng)))
     .then(() => assert.called(spy));
 });
Example #2
0
 it(`adds a tracking id to each request`, () => {
   return spark.request({
     uri: makeLocalUrl(`/`),
     headers: {
       authorization: false
     }
   })
     .then((res) => {
       assert.property(res.options.headers, `trackingid`);
     });
 });
module.exports = function createUser(options) {
  return fetch(makeLocalUrl('/jwt'), {
    method: 'POST',
    headers: new Headers({
      'content-type': 'application/json'
    }),
    body: JSON.stringify(options)
  })
    .then((res) => res.json())
    .then((body) => body.jwt);
};
Example #4
0
 it(`fails with a SparkHttpError`, () => {
   return assert.isRejected(spark.request({
     uri: makeLocalUrl(`/not-a-route`),
     headers: {
       authorization: false
     }
   }))
     .then((err) => {
       assert.instanceOf(err, SparkHttpError);
       assert.instanceOf(err, SparkHttpError.BadRequest);
     });
 });
Example #5
0
 it(`downloads and decrypts a non-encrypted file`, () => spark.internal.conversation.download({url: makeLocalUrl(`/sample-image-small-one.png`)})
   .then((f) => assert.eventually.isTrue(fh.isMatchingFile(f, sampleImageSmallOnePng))));