|
| 1 | +var lambdaTunnel = require('../index'); |
1 | 2 | var chai = require('chai'); |
2 | 3 | var expect = chai.expect; |
| 4 | + |
3 | 5 | describe('Tunnel runs successfully', function() { |
| 6 | + var isTunnelStarted = false; |
| 7 | + beforeEach(function(done) { |
| 8 | + //start tunnel |
| 9 | + this.timeout(20000); |
| 10 | + var tunnelInstance = new lambdaTunnel(); |
| 11 | + // replace <lambdatest-user> with your user and <lambdatest-accesskey> with your key. |
| 12 | + var tunnelArguments = { |
| 13 | + user: process.env.LT_USERNAME || '<lambdatest-user>', |
| 14 | + key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>' |
| 15 | + }; |
| 16 | + try { |
| 17 | + tunnelInstance.start(tunnelArguments, function(error, status) { |
| 18 | + if (!error) { |
| 19 | + isTunnelStarted = true; |
| 20 | + tunnelInstance.stop().then(status => { |
| 21 | + console.log('Tunnel is Stopped ? ' + status); |
| 22 | + }); |
| 23 | + done(); |
| 24 | + } |
| 25 | + }); |
| 26 | + } catch (error) { |
| 27 | + isTunnelStarted = false; |
| 28 | + } |
| 29 | + }); |
4 | 30 | it('Tunnel doesnt start on wrong parameter', function() { |
5 | | - var isTunnelStarted = false; |
6 | | - before(function() { |
7 | | - this.timeout('10sec'); |
8 | | - //creates an instance of Tunnel |
9 | | - var tunnelInstance = new lambdaTunnel(); |
10 | | - // replace <lambdatest-user> with your user and <lambdatest-accesskey> with your key. |
11 | | - var tunnelArguments = { |
12 | | - user: process.env.LT_USERNAME || '<lambdatest-user>', |
13 | | - key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>' |
14 | | - }; |
15 | | - try { |
16 | | - tunnelInstance.start(tunnelArguments, function(error, status) { |
17 | | - if (!error) { |
18 | | - isTunnelStarted = true; |
19 | | - } |
20 | | - }); |
21 | | - } catch (error) { |
22 | | - isTunnelStarted = false; |
23 | | - } |
24 | | - }); |
25 | 31 | expect(typeof isTunnelStarted).to.equal('boolean'); |
| 32 | + expect(isTunnelStarted).to.equal(true); |
26 | 33 | }); |
27 | 34 | }); |
0 commit comments