| Total Complexity | 8 |
| Complexity/F | 1 |
| Lines of Code | 33 |
| Function Count | 8 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | import { delay } from 'bluebird'; |
||
| 2 | import { expect } from 'chai'; |
||
| 3 | import path from 'path'; |
||
| 4 | import intercept from 'intercept-stdout'; |
||
| 5 | import { createStream } from './helper'; |
||
| 6 | |||
| 7 | describe('run.js', () => { |
||
| 8 | describe('Execution', () => { |
||
| 9 | it('should execute a hello world', () => { |
||
| 10 | process.chdir(path.join(__dirname, 'data/hello-world')); |
||
| 11 | const stream = createStream(['run'], '../../../dist/cli.js'); |
||
| 12 | |||
| 13 | return stream.once('data') |
||
| 14 | .then(askName => { |
||
| 15 | expect(askName).to.match(/What is your name/); |
||
| 16 | return stream.write('Harmony\n\n'); |
||
| 17 | }) |
||
| 18 | .then(() => { |
||
| 19 | let result = ''; |
||
| 20 | const stopReading = intercept(text => result += text); |
||
| 21 | return delay(5000) |
||
| 22 | .then(() => { |
||
| 23 | stopReading(); |
||
| 24 | expect(result).to.equals(''); |
||
| 25 | }); |
||
| 26 | }) |
||
| 27 | .finally(() => { |
||
| 28 | stream.close(); |
||
| 29 | process.chdir(path.join(__dirname, '..')); |
||
| 30 | }); |
||
| 31 | }).timeout(25000); |
||
| 32 | }); |
||
| 33 | }); |
||
| 34 |