Add sourceMapTransformer test for changes today

This commit is contained in:
Rob 2015-10-28 19:15:39 -07:00
Родитель 904b797c27
Коммит 9e12e31dde
3 изменённых файлов: 29 добавлений и 12 удалений

Просмотреть файл

@ -4,6 +4,7 @@
import * as assert from 'assert';
import * as mockery from 'mockery';
import * as testUtils from '../../testUtils';
import { ISourceMaps, MappingResult } from '../../../adapter/sourceMaps/sourceMaps';
const MODULE_UNDER_TEST = '../../../adapter/sourceMaps/sourceMapTransformer';
@ -13,9 +14,12 @@ const AUTHORED_LINES = [1, 2, 3];
const RUNTIME_LINES = [2, 5, 8];
const RUNTIME_COLS = [3, 7, 11];
// Not mocked, use for type only
import {SourceMapTransformer as _SourceMapTransformer} from '../../../adapter/sourceMaps/sourceMapTransformer';
suite('SourceMapTransformer', () => {
let transformer: IDebugTransformer;
let transformerSMDisabled: IDebugTransformer;
let transformer: _SourceMapTransformer;
let transformerSMDisabled: _SourceMapTransformer;
setup(() => {
// Set up mockery with SourceMaps mock
@ -58,15 +62,15 @@ suite('SourceMapTransformer', () => {
const args = createArgs(AUTHORED_PATH, AUTHORED_LINES);
const expected = createArgs(RUNTIME_PATH, RUNTIME_LINES, RUNTIME_COLS);
transformer.setBreakpoints(args);
transformer.setBreakpoints(args, 0);
assert.deepEqual(args, expected);
});
test('doesn\'t do anything when sourcemaps are disabled', () => {
test(`doesn't do anything when sourcemaps are disabled`, () => {
const args = createArgs(RUNTIME_PATH, RUNTIME_LINES);
const expected = createArgs(RUNTIME_PATH, RUNTIME_LINES);
transformerSMDisabled.setBreakpoints(args);
transformerSMDisabled.setBreakpoints(args, 0);
assert.deepEqual(args, expected);
});
@ -91,20 +95,20 @@ suite('SourceMapTransformer', () => {
transformer.setBreakpoints(<DebugProtocol.SetBreakpointsArguments>{
source: { path: AUTHORED_PATH },
lines: AUTHORED_LINES
});
transformer.setBreakpointsResponse(response);
}, 0);
transformer.setBreakpointsResponse(response, 0);
assert.deepEqual(response, expected);
});
test('doesn\'t do anything when sourcemaps are disabled except remove the column', () => {
test(`doesn't do anything when sourcemaps are disabled except remove the column`, () => {
const response = getResponseBody(RUNTIME_LINES, /*column=*/0);
const expected = getResponseBody(RUNTIME_LINES);
transformerSMDisabled.setBreakpoints(<DebugProtocol.SetBreakpointsArguments>{
source: { path: RUNTIME_PATH },
lines: RUNTIME_LINES
});
transformerSMDisabled.setBreakpointsResponse(response);
}, 0);
transformerSMDisabled.setBreakpointsResponse(response, 0);
assert.deepEqual(response, expected);
});
});
@ -139,6 +143,12 @@ suite('SourceMapTransformer', () => {
assert.deepEqual(response, expected);
});
});
suite('scriptParsed()', () => {
test('calls MapToSource', () => {
transformer.scriptParsed(new testUtils.MockEvent('scriptParsed', { scriptUrl: RUNTIME_PATH }));
});
});
});
class MockSourceMaps implements ISourceMaps {

Просмотреть файл

@ -13,3 +13,10 @@ export function removeUnhandledRejectionListener(): void {
function unhandledRejectionListener(reason, p) {
console.log(`ERROR!! Unhandled promise rejection: ${reason}`);
}
export class MockEvent implements DebugProtocol.Event {
public seq = 0;
public type = 'event';
constructor(public event: string, public body?: any) { }
}

Просмотреть файл

@ -111,7 +111,7 @@ suite('WebKitDebugAdapter', () => {
function makeExpectedResponse(lines: number[], cols?: number[]): SetBreakpointsResponseBody {
const breakpoints = lines.map((line, i) => ({
line,
column: cols? cols[i] : 0,
column: cols ? cols[i] : 0,
verified: true
}));
@ -178,7 +178,7 @@ suite('WebKitDebugAdapter', () => {
}).then(response => {
lines.push(321);
cols.push(123);
expectRemoveBreakpoint([0, 1]);
expectSetBreakpoint(lines, cols);
return wkda.setBreakpoints({ source: { path: FILE_NAME }, lines, cols });