diff options
author | Maximilian Krambach <[email protected]> | 2018-08-30 13:00:19 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-08-30 13:00:19 +0000 |
commit | 3201ded91f91fcdf501ad966380b6ff29d798b09 (patch) | |
tree | 31db36d9654b9e5f48475e9723e2fa097ca6c4e0 /lang/js/BrowserTestExtension/tests/encryptTest.js | |
parent | js: add encoding parameter for encrypt return (diff) | |
download | gpgme-3201ded91f91fcdf501ad966380b6ff29d798b09.tar.gz gpgme-3201ded91f91fcdf501ad966380b6ff29d798b09.zip |
js: add tests
--
* BrowserTestExtension/tests:
- decryptTest.js: Check Decryption and return values of binary data
- encryptTest.js: Return data type of armored/non-armored encryption
- added a small encoded input png for testing
* DemoExtension/maindemo.js: Fixed unexpected usage of the Demo encrypt
(non-armored)
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 + }); |