.then(() => {
   expect(service.sendFile.calledOnce)
     .to.eql(true);
   expect(res.status.calledOnce).to.eql(true);
   expect(res.status.calledWith(httpStatus.OK)).to.eql(true);
   expect(res.send.calledOnce).to.eql(true);
 })
 it('does not start app insights if instrumentationKey is not set', () => {
   delete config.services.applicationInsights.instrumentationKey;
   appInsights();
   expect(applicationinsights.setup.calledOnce).to.eql(false);
   expect(appInsightsStub.setAutoCollectConsole.calledOnce).to.eql(false);
   expect(appInsightsStub.start.calledOnce).to.eql(false);
 });
    it('hasBeenChanges : yes ', () => {
      const changesDetailsVal = 'details...';
      const fields = {
        changes: {
          hasBeenChanges: 'yes',
          changesDetails: changesDetailsVal,
          statementOfTruthNoChanges: 'yes',
          statementOfTruthChanges: 'yes'
        }
      };
      const req = {
        journey: {},
        session: { MiniPetition: fields }
      };

      const res = {};
      const step = new MiniPetition(req, res);
      step.retrieve().validate();

      const _values = step.values();
      expect(_values).to.be.an('object');
      expect(_values).to.have.property('changes.statementOfTruthChanges', 'yes');
      expect(_values).to.have.property('changes.changesDetails', changesDetailsVal);
      expect(_values).to.not.have.property('changes.statementOfTruthNoChanges');
    });
 it('should default to unknown error if we dont know it', () => {
   req.query.js = true;
   evidenceManagmentMiddleware.errorHandler({ code: 'an unknown error' }, req, res, next);
   expect(res.status.calledOnce).to.eql(true);
   expect(res.send.calledWith(evidenceManagmentMiddleware.errors.unknown))
     .to.eql(true);
 });
 it('starts app insights if instrumentationKey is set', () => {
   config.services.applicationInsights.instrumentationKey = 'a value';
   appInsights();
   expect(applicationinsights.setup.calledOnce).to.eql(true);
   expect(appInsightsStub.setAutoCollectConsole.calledOnce).to.eql(true);
   expect(appInsightsStub.start.calledOnce).to.eql(true);
   expect(applicationinsights.defaultClient.context.tags.someKey).to.eql('div-dn');
 });
 .then(() => {
   expect(res.status.calledOnce).to.eql(true);
   expect(res.status.calledWith(
     evidenceManagmentMiddleware.errors.unknown.status
   )).to.eql(true);
   expect(res.send.calledOnce).to.eql(true);
   expect(res.send.calledWith(
     evidenceManagmentMiddleware.errors.unknown
   )).to.eql(true);
 })
 it('return status code and message if js request', () => {
   req.query.js = true;
   evidenceManagmentMiddleware.errorHandler(
     evidenceManagmentMiddleware.errors.maximumFilesExceeded,
     req,
     res,
     next
   );
   expect(res.status.calledOnce).to.eql(true);
   expect(res.send.calledOnce).to.eql(true);
 });
 it('calls step standard validation and redirects to show errors', () => {
   evidenceManagmentMiddleware.errorHandler(
     evidenceManagmentMiddleware.errors.maximumFilesExceeded,
     req,
     res,
     next
   );
   expect(req.currentStep.parse.calledOnce).to.eql(true);
   expect(req.currentStep.validate.calledOnce).to.eql(true);
   expect(req.currentStep.storeErrors.calledOnce).to.eql(true);
   expect(res.redirect.calledOnce).to.eql(true);
 });
    it('should return error if files are more than 10', done => {
      const req = { session: {} };
      req.session[nameSpace] = { files: [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ] };

      expect(evidenceManagmentMiddleware.validatePostRequest(req, nameSpace))
        .to
        .be
        .rejectedWith(evidenceManagmentMiddleware.errors.maximumFilesExceeded)
        .and.notify(done);
    });
 it('remove all errors from session', () => {
   const req = {
     session: {
       errorMaximumFilesExceeded: 'invalid',
       errorFileTypeInvalid: 'invalid'
     }
   };
   evidenceManagmentMiddleware.resetAllErrors(req);
   expect(req.session).to.eql({});
 });
 it('should add existing files from session into body', () => {
   req.session.stepName = {
     files: [{ fileName: 'existing file' }]
   };
   evidenceManagmentMiddleware.errorHandler({ code: 'an unknown error' }, req, res, next);
   expect(req.body).to.eql({
     files: [
       { fileName: 'existing file' },
       { error: 'errorUnknown' }
     ]
   });
 });
 .then(() => {
   expect(req.session[nameSpace].files).to
     .eql([{ fileName: file2, fileUrl: file2 }]);
 })
 .then(result => {
   expect(result).to.eql(req);
 })
 .then(() => {
   expect(req.session[nameSpace].files.length).to.eql(two);
   expect(req.session[nameSpace].files[1]).to.eql(files[0]);
 })
Ejemplo n.º 15
0
 it('should the string in upper case', () => {
   const string = 'this is some text';
   const stringFormatted = string.toUpperCase();
   expect(upper.upper(string)).to.eql(stringFormatted);
 });
Ejemplo n.º 16
0
 .catch(error => {
   expect(error).to.eql(false, `Error with WC3 module: ${error}`);
 });
Ejemplo n.º 17
0
 it('should return address formatted', () => {
   const addressToFormat = ['line 1', 'line 2', 'line 3'];
   const addressFormatted = addressToFormat.join('<br>');
   expect(filter.address(addressToFormat)).to.eql(addressFormatted);
 });
Ejemplo n.º 18
0
 it('should not generate any warnings', () => {
   expect(warnings.length).to.equal(0, JSON.stringify(warnings, null, 2));
 });
 it('should call next not delete or post or submit button pressed', () => {
   req.method = 'get';
   expressHandler(req, res, next);
   expect(next.calledOnce).to.eql(true);
 });
 it('should call next if submit button pressed', () => {
   req.body = { submit: true };
   expressHandler(req, res, next);
   expect(next.calledOnce).to.eql(true);
 });
Ejemplo n.º 21
0
 it('should not have any html errors', () => {
   expect(errors.length).to.equal(0, JSON.stringify(errors, null, 2));
 });
 .then(() => {
   expect(res.redirect.calledOnce).to.eql(true);
 })
 .then(() => {
   expect(req.session[nameSpace].files.length).to.eql(0);
   expect(res.status.calledOnce).to.eql(true);
   expect(res.send.calledOnce).to.eql(true);
 })
 .then(() => {
   expect(service.sendFile.calledOnce)
     .to.eql(true);
   expect(req.session[nameSpace].files.length).to.eql(1);
   expect(res.redirect.calledOnce).to.eql(true);
 })
 it('returns express handler', () => {
   expressHandler = evidenceManagmentMiddleware.createHandler(nameSpace);
   expect(typeof expressHandler).to.eql('function');
 });
Ejemplo n.º 26
0
 it('should not generate any errors', () => {
   expect(errors.length).to.equal(0, JSON.stringify(errors, null, 2));
 });
Ejemplo n.º 27
0
 it('should not have any html warnings', () => {
   expect(warnings.length).to.equal(0, JSON.stringify(warnings, null, 2));
 });
Ejemplo n.º 28
0
 .catch(error => {
   expect(error).to.eql(false, `Error when validating HTML accessibility: ${error}`);
 });
Ejemplo n.º 29
0
 it('should return string if not array', () => {
   const addressFormatted = 'address as string';
   expect(filter.address(addressFormatted)).to.eql(addressFormatted);
 });