js: more testing of nativeMessaging connection
[gpgme.git] / lang / js / BrowserTestExtension / tests / longRunningTests.js
1 describe('Long running Encryption/Decryption', function () {
2     for (let i=0; i< 100; i++) {
3         it('Successful encrypt/decrypt completely random data ' + (i+1) + '/100', function (done) {
4             let prm = Gpgmejs.init();
5             let data = bigString(2);
6                 prm.then(function (context) {
7                     context.encrypt(data,
8                         inputvalues.encrypt.good.fingerprint).then(
9                             function (answer){
10                                 expect(answer).to.not.be.empty;
11                                 expect(answer.data).to.be.a("string");
12                                 expect(answer.data).to.include(
13                                     'BEGIN PGP MESSAGE');
14                                 expect(answer.data).to.include(
15                                     'END PGP MESSAGE');
16                                 context.decrypt(answer.data).then(
17                                     function(result){
18                                         expect(result).to.not.be.empty;
19                                         expect(result.data).to.be.a('string');
20                                         expect(result.data).to.equal(data);
21                                         context.connection.disconnect();
22                                         done();
23                                 });
24                         });
25                 });
26         }).timeout(5000);
27     };
28
29     it('Successful encrypt 1 MB Uint8Array', function (done) {
30         let prm = Gpgmejs.init();
31         let data = bigUint8(1);
32         prm.then(function (context) {
33                 context.encrypt(data,
34                     inputvalues.encrypt.good.fingerprint).then(
35                         function (answer){
36                             expect(answer).to.not.be.empty;
37                             expect(answer.data).to.be.a("string");
38                             expect(answer.data).to.include(
39                                 'BEGIN PGP MESSAGE');
40                             expect(answer.data).to.include(
41                                 'END PGP MESSAGE');
42                             context.decrypt(answer.data).then(
43                                 function(result){
44                                     expect(result).to.not.be.empty;
45                                     expect(result.data).to.be.a('string');
46                                     expect(result.data).to.equal(data);
47                                     done();
48                             });
49                     });
50             });
51     }).timeout(5000);
52
53 });