Completed
Push — master ( 8c53f9...1d869a )
by Marcelo
33s
created

test/run.spec.js   A

Complexity

Total Complexity 8
Complexity/F 1

Size

Lines of Code 33
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
wmc 8
c 2
b 0
f 0
nc 1
mnd 0
bc 7
fnc 8
dl 0
loc 33
rs 10
bpm 0.875
cpm 1
noi 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