Skip to content

Commit 4e947e7

Browse files
committed
Increase tests code coverage for new code
1 parent 4fff31d commit 4e947e7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/odo.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import * as sinon from 'sinon';
1010
import * as chai from 'chai';
1111
import * as sinonChai from 'sinon-chai';
1212
import { ToolsConfig } from '../src/tools';
13+
import { WindowUtil } from '../src/util/windowUtils';
1314
import { window } from 'vscode';
15+
import { Terminal } from 'vscode';
1416
import jsYaml = require('js-yaml');
1517
import { TestItem } from './openshift/testOSItem';
1618
import { ExecException } from 'child_process';
1719
import * as fs from 'fs';
20+
import * as path from 'path';
1821

1922
const expect = chai.expect;
2023
chai.use(sinonChai);
@@ -86,6 +89,24 @@ suite("odo", () => {
8689

8790
expect(result).deep.equals({ error: err, stdout: '', stderr: '' });
8891
});
92+
93+
test('executeInTerminal send command to terminal and shows it', async () => {
94+
const termFake: Terminal = {
95+
name: "name",
96+
processId: Promise.resolve(1),
97+
sendText: sinon.stub(),
98+
show: sinon.stub(),
99+
hide: sinon.stub(),
100+
dispose: sinon.stub()
101+
};
102+
toolsStub.restore();
103+
toolsStub = sandbox.stub(ToolsConfig, 'detectOrDownload').resolves(path.join('segment1', 'segment2'));
104+
let ctStub = sandbox.stub(WindowUtil, 'createTerminal').returns(termFake);
105+
await odoCli.executeInTerminal('cmd');
106+
expect(termFake.sendText).calledOnce;
107+
expect(termFake.show).calledOnce;
108+
expect(ctStub).calledWith('OpenShift', process.cwd(), 'segment1');
109+
});
89110
});
90111

91112
suite('item listings', () => {

0 commit comments

Comments
 (0)