Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Fix test linting
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jun 7, 2018
1 parent 0bf1e63 commit c54e7fa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 39 deletions.
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const scripts = [
];

const lintSources = [
'src'
'src',
'test'
].map(function (tsFolder) { return tsFolder + '/**/*.ts'; });

const tsProject = ts.createProject('tsconfig.json', { typescript });
Expand Down
70 changes: 32 additions & 38 deletions test/chromeDebugAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import { DebugProtocol } from 'vscode-debugprotocol';
import { chromeConnection, ISourceMapPathOverrides, telemetry, utils as coreUtils, ChromeDebugSession } from 'vscode-chrome-debug-core';

import * as mockery from 'mockery';
import { EventEmitter } from 'events';
import * as assert from 'assert';
import { Mock, MockBehavior, It, IMock, Times } from 'typemoq';

import { EventEmitter } from 'events';
import * as mockery from 'mockery';
import { IMock, It, Mock, MockBehavior, Times } from 'typemoq';
import { chromeConnection, ISourceMapPathOverrides, telemetry } from 'vscode-chrome-debug-core';
import { DebugProtocol } from 'vscode-debugprotocol';
import { ChromeDebugAdapter as _ChromeDebugAdapter } from '../src/chromeDebugAdapter';
import { getMockChromeConnectionApi, IMockChromeConnectionAPI } from './debugProtocolMocks';
import * as testUtils from './testUtils';

/** Not mocked - use for type only */
import {ChromeDebugAdapter as _ChromeDebugAdapter } from '../src/chromeDebugAdapter';

class MockChromeDebugSession {
public sendEvent(event: DebugProtocol.Event): void {
}
Expand Down Expand Up @@ -160,26 +156,26 @@ suite('ChromeDebugAdapter', () => {
let collectedLaunchParams: any;
mockChromeDebugSession
.setup(x => x.sendRequest('launchUnelevated',
It.is((x: any) => {
collectedLaunchParams = x;
return true;
}),
10000,
It.is(
(callback: (response: DebugProtocol.Response) => void) => {
callback({
seq: null,
type: 'command',
request_seq: 100,
command: 'launchUnelevated',
success: true,
body: {
processId: expectedProcessId
}
});
It.is((param: any) => {
collectedLaunchParams = param;
return true;
})))
.verifiable(Times.atLeast(1));
}),
10000,
It.is(
(callback: (response: DebugProtocol.Response) => void) => {
callback({
seq: null,
type: 'command',
request_seq: 100,
command: 'launchUnelevated',
success: true,
body: {
processId: expectedProcessId
}
});
return true;
})))
.verifiable(Times.atLeast(1));

await chromeDebugAdapter.launch({
file: 'c:\\path with space\\index.html',
Expand All @@ -192,19 +188,19 @@ suite('ChromeDebugAdapter', () => {
assert(collectedLaunchParams.process.match(/chrome/i));
assert(collectedLaunchParams.args != null);

assert(collectedLaunchParams.args.filter((x) => x == '--no-default-browser-check').length != 0,
assert(collectedLaunchParams.args.filter(arg => arg === '--no-default-browser-check').length !== 0,
'Should have seen the --no-default-browser-check parameter');
assert(collectedLaunchParams.args.filter((x) => x == '--no-first-run').length != 0,
assert(collectedLaunchParams.args.filter(arg => arg === '--no-first-run').length !== 0,
'Should have seen the --no-first-run parameter');
assert(collectedLaunchParams.args.filter((x) => x == 'abc').length != 0,
assert(collectedLaunchParams.args.filter(arg => arg === 'abc').length !== 0,
'Should have seen the abc parameter');
assert(collectedLaunchParams.args.filter((x) => x == 'def').length != 0,
assert(collectedLaunchParams.args.filter(arg => arg === 'def').length !== 0,
'Should have seen the def parameter');
assert(collectedLaunchParams.args.filter((x) => x == 'about:blank').length != 0,
assert(collectedLaunchParams.args.filter(arg => arg === 'about:blank').length !== 0,
'Should have seen the about:blank parameter');
assert(collectedLaunchParams.args.filter((x) => x.match(/remote-debugging-port/)).length != 0,
assert(collectedLaunchParams.args.filter(arg => arg.match(/remote-debugging-port/)).length !== 0,
'Should have seen a parameter like remote-debugging-port');
assert(collectedLaunchParams.args.filter((x) => x.match(/user-data-dir/)).length != 0,
assert(collectedLaunchParams.args.filter(arg => arg.match(/user-data-dir/)).length !== 0,
'Should have seen a parameter like user-data-dir');

const telemetryProperties = telemetryPropertyCollector.getProperties();
Expand All @@ -213,8 +209,6 @@ suite('ChromeDebugAdapter', () => {

require('os').platform = originalGetPlatform;
require('../src/utils').getBrowserPath = originalGetBrowser;

return Promise.resolve();
});
});

Expand Down

0 comments on commit c54e7fa

Please sign in to comment.