Skip to content

Commit e260ac6

Browse files
committed
Fix unit test error
Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent ef7cc15 commit e260ac6

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

test/unit/openshift/component.test.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ suite('OpenShift/Component', () => {
4747
const s2iComponentItem = new TestItem(appItem, 'compDev', ContextType.COMPONENT_PUSHED,[], comp2Uri, '/path', SourceType.LOCAL)
4848
const serviceItem = new TestItem(appItem, 'service', ContextType.SERVICE);
4949
const errorMessage = 'FATAL ERROR';
50+
let getApps: sinon.SinonStub;
5051
let Component: any;
5152
let fetchTag: sinon.SinonStub;
5253
let commandStub: sinon.SinonStub;
@@ -66,19 +67,38 @@ suite('OpenShift/Component', () => {
6667
sandbox.stub(OdoImpl.prototype, 'getApplications').resolves([]);
6768
getComponentsStub = sandbox.stub(OdoImpl.prototype, 'getComponents').resolves([]);
6869
sandbox.stub(Util, 'wait').resolves();
70+
getApps = sandbox.stub(OpenShiftItem, 'getApplicationNames').resolves([appItem]);
6971
sandbox.stub(OpenShiftItem, 'getComponentNames').resolves([componentItem]);
7072
sandbox.stub(OpenShiftItem, 'getServiceNames').resolves([serviceItem]);
71-
commandStub = sandbox.stub(vscode.commands, 'executeCommand');
73+
commandStub = sandbox.stub(vscode.commands, 'executeCommand').resolves();
7274
sandbox.stub()
7375
});
7476

7577
teardown(() => {
7678
sandbox.restore();
7779
});
7880

79-
suite('reveal in explorer called revealInExplorer with component\'s context', () => {
80-
Component.revealContextInExplorer(componentItem);
81-
expect(commandStub).calledWith(componentItem.contextPath);
81+
suite('create component with no context', () => {
82+
83+
setup(() => {
84+
quickPickStub = sandbox.stub(vscode.window, 'showQuickPick');
85+
quickPickStub.onFirstCall().resolves(undefined);
86+
});
87+
88+
test('asks for context and exits if not provided', async () => {
89+
const result = await Component.create(null);
90+
expect(result).null;
91+
expect(getApps).calledOnce;
92+
});
93+
});
94+
95+
suite('reveal in explorer', () => {
96+
97+
test('called revealInExplorer with component\'s context', async () => {
98+
await Component.revealContextInExplorer(componentItem);
99+
expect(commandStub).calledWith('revealInExplorer', componentItem.contextPath);
100+
});
101+
82102
});
83103

84104
suite('create', () => {

0 commit comments

Comments
 (0)