Kube Service tests (#13183)

This commit is contained in:
Arvind Ranasaria
2020-11-03 15:46:31 -08:00
committed by GitHub
parent 7bdb7c328a
commit 3ec1f7cc2b
4 changed files with 108 additions and 28 deletions

View File

@@ -3,10 +3,12 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import assert = require('assert');
import * as TypeMoq from 'typemoq';
import { ToolsService } from '../../services/toolsService';
import { ITool, ToolType } from '../../interfaces';
import { IPlatformService } from '../../services/platformService';
import { ToolsService } from '../../services/toolsService';
const tools: { name: string; type: ToolType }[] = [
@@ -30,12 +32,12 @@ describe('Tools Service Tests', function (): void {
}
}
}
(missingTypes.length === 0).should.be.true(`the following enum values are not included in the test:${missingTypes.join(',')}`);
assert(missingTypes.length === 0, `the following enum values are not included in the test:${missingTypes.join(',')}`);
tools.forEach(toolInfo => {
const tool = toolsService.getToolByName(toolInfo.name);
(!!tool).should.be.true(`The tool: ${toolInfo.name} is not recognized`);
(tool!.type).should.equal(toolInfo.type, 'returned notebook name does not match expected value');
assert(!!tool, `The tool: ${toolInfo.name} is not recognized`);
assert.equal(tool!.type, toolInfo.type, 'returned notebook name does not match expected value');
});
});
@@ -43,17 +45,17 @@ describe('Tools Service Tests', function (): void {
const mockPlatformService = TypeMoq.Mock.ofType<IPlatformService>();
const toolsService = new ToolsService(mockPlatformService.object);
const tool = toolsService.getToolByName('no-such-tool');
(tool === undefined).should.be.true('for a not defined tool, expected value is undefined');
assert(tool === undefined, 'for a not defined tool, expected value is undefined');
});
it('get/set tools for CurrentProvider', () => {
const iTools: ITool[] = tools.map(toolInfo => {
const tool = toolsService.getToolByName(toolInfo.name);
(!!tool).should.be.true(`The tool: ${toolInfo.name} is not recognized`);
tool!.type.should.equal(toolInfo.type, 'returned notebook name does not match expected value');
assert(!!tool, `The tool: ${toolInfo.name} is not recognized`);
assert.equal(tool!.type, toolInfo.type, 'returned notebook name does not match expected value');
return tool!;
});
toolsService.toolsForCurrentProvider = iTools;
iTools.should.deepEqual(toolsService.toolsForCurrentProvider, 'toolsForCurrentProvider did not return the value we set');
assert.deepEqual(iTools, toolsService.toolsForCurrentProvider, 'toolsForCurrentProvider did not return the value we set');
});
});