diff options
Diffstat (limited to 'lang/js/BrowserTestExtension/tests/encryptTest.js')
| -rw-r--r-- | lang/js/BrowserTestExtension/tests/encryptTest.js | 45 | 
1 files changed, 43 insertions, 2 deletions
diff --git a/lang/js/BrowserTestExtension/tests/encryptTest.js b/lang/js/BrowserTestExtension/tests/encryptTest.js index ccdb4994..d97b458d 100644 --- a/lang/js/BrowserTestExtension/tests/encryptTest.js +++ b/lang/js/BrowserTestExtension/tests/encryptTest.js @@ -22,7 +22,7 @@   */  /* global describe, it, expect, before, Gpgmejs */ -/* global inputvalues, fixedLengthString */ +/* global inputvalues, fixedLengthString, bigString */  describe('Encryption', function () {      let context = null; @@ -47,6 +47,47 @@ describe('Encryption', function () {              });      }); + +    it( 'encrypt with \'armor\': true should returned an armored block', +        function (done){ +            const data = bigString(1000); +            context.encrypt({ data: data, publicKeys: good_fpr, armor: true }) +                .then(function (answer){ +                    expect(answer).to.not.be.empty; +                    expect(answer.data).to.be.a('string'); +                    expect(answer.data).to.include('BEGIN PGP MESSAGE'); +                    expect(answer.data).to.include('END PGP MESSAGE'); +                    expect(answer.format).to.equal('ascii'); +                    done(); +                }); +        }); + +    it( 'encrypt with \'armor\': false and \'expected\': \'uint8\' returns ' + +    'an Uint8Array', function (done) { +        const data = bigString(1000); +        context.encrypt({ +            data: data, publicKeys: good_fpr, armor: false, expect: 'uint8' +        }).then(function (answer){ +            expect(answer).to.not.be.empty; +            expect(answer.data).to.be.a('Uint8Array'); +            expect(answer.format).to.equal('uint8'); +            done(); +        }); +    }); + +    it( 'encrypt with \'armor\': false and \'expected\': \'base64\' returns ' + +        'a base64 string', function (done) { +        const data = bigString(1000); +        context.encrypt({ +            data: data, publicKeys: good_fpr, armor: false, expect: 'base64' +        }).then(function (answer){ +            expect(answer).to.not.be.empty; +            expect(answer.data).to.be.a('string'); +            expect(answer.format).to.equal('base64'); +            done(); +        }); +    }); +      const sizes = [5,20,50];      for (let i=0; i < sizes.length; i++) {          it('Successful encrypt a ' + sizes[i] + 'MB message', function (done) { @@ -114,5 +155,5 @@ describe('Encryption', function () {              });      }).timeout(8000); -    // TODO check different valid parameter +  });  | 
