Add Jupyter Notebook Manager Tests (#10955)

* jupyter notebook manager tests

* cover config duplicate integrationTest
This commit is contained in:
Chris LaFreniere
2020-06-17 14:42:35 -07:00
committed by GitHub
parent 8b68d524ee
commit 77ba5a36aa
2 changed files with 116 additions and 12 deletions

View File

@@ -64,7 +64,7 @@ describe('Local Jupyter Server Manager', function (): void {
it('Should configure and start install', async function (): Promise<void> {
// Given an install and instance that start with no issues
let expectedUri = vscode.Uri.parse('http://localhost:1234?token=abcdefghijk');
let mockServerInstance = initInstallAndInstance(expectedUri);
let mockServerInstance = initInstallAndInstance(expectedUri, mockFactory);
deferredInstall.resolve();
// When I start the server
@@ -89,7 +89,7 @@ describe('Local Jupyter Server Manager', function (): void {
it('Should call stop on server instance', async function (): Promise<void> {
// Given an install and instance that start with no issues
let expectedUri = vscode.Uri.parse('http://localhost:1234?token=abcdefghijk');
let mockServerInstance = initInstallAndInstance(expectedUri);
let mockServerInstance = initInstallAndInstance(expectedUri, mockFactory);
mockServerInstance.setup(s => s.stop()).returns(() => Promise.resolve());
deferredInstall.resolve();
@@ -104,7 +104,7 @@ describe('Local Jupyter Server Manager', function (): void {
it('Should call stop when extension is disposed', async function (): Promise<void> {
// Given an install and instance that start with no issues
let expectedUri = vscode.Uri.parse('http://localhost:1234?token=abcdefghijk');
let mockServerInstance = initInstallAndInstance(expectedUri);
let mockServerInstance = initInstallAndInstance(expectedUri, mockFactory);
mockServerInstance.setup(s => s.stop()).returns(() => Promise.resolve());
deferredInstall.resolve();
@@ -116,13 +116,13 @@ describe('Local Jupyter Server Manager', function (): void {
// Then I expect stop to have been called on the server instance
mockServerInstance.verify(s => s.stop(), TypeMoq.Times.once());
});
function initInstallAndInstance(uri: vscode.Uri): TypeMoq.IMock<IServerInstance> {
let mockServerInstance = TypeMoq.Mock.ofType(JupyterServerInstanceStub);
mockFactory.setup(f => f.createInstance(TypeMoq.It.isAny())).returns(() => mockServerInstance.object);
mockServerInstance.setup(s => s.configure()).returns(() => Promise.resolve());
mockServerInstance.setup(s => s.start()).returns(() => Promise.resolve());
mockServerInstance.setup(s => s.uri).returns(() => uri);
return mockServerInstance;
}
});
export function initInstallAndInstance(uri: vscode.Uri, mockFactory: TypeMoq.IMock<ServerInstanceFactory>): TypeMoq.IMock<IServerInstance> {
let mockServerInstance = TypeMoq.Mock.ofType(JupyterServerInstanceStub);
mockFactory.setup(f => f.createInstance(TypeMoq.It.isAny())).returns(() => mockServerInstance.object);
mockServerInstance.setup(s => s.configure()).returns(() => Promise.resolve());
mockServerInstance.setup(s => s.start()).returns(() => Promise.resolve());
mockServerInstance.setup(s => s.uri).returns(() => uri);
return mockServerInstance;
}