本文整理匯總了TypeScript中vs/editor/test/common/viewModel/testViewModel.testViewModel函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript testViewModel函數的具體用法?TypeScript testViewModel怎麽用?TypeScript testViewModel使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了testViewModel函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('issue #44805: SplitLinesCollection: attempt to access a \'newer\' model', () => {
const text = [''];
testViewModel(text, {}, (viewModel, model) => {
assert.equal(viewModel.getLineCount(), 1);
model.pushEditOperations([], [{
range: new Range(1, 1, 1, 1),
text: '\ninsert1'
}], () => ([]));
model.pushEditOperations([], [{
range: new Range(1, 1, 1, 1),
text: '\ninsert2'
}], () => ([]));
model.pushEditOperations([], [{
range: new Range(1, 1, 1, 1),
text: '\ninsert3'
}], () => ([]));
let viewLineCount: number[] = [];
viewLineCount.push(viewModel.getLineCount());
viewModel.addEventListener((events) => {
// Access the view model
viewLineCount.push(viewModel.getLineCount());
});
model.undo();
viewLineCount.push(viewModel.getLineCount());
assert.deepEqual(viewLineCount, [4, 1, 1, 1]);
});
});
示例2: test
test('issue #37401: Allow both before and after decorations on empty line', () => {
const text = [
''
];
testViewModel(text, {}, (viewModel, model) => {
model.changeDecorations((accessor) => {
accessor.addDecoration(
new Range(1, 1, 1, 1),
{
beforeContentClassName: 'before1',
afterContentClassName: 'after1'
}
);
});
let inlineDecorations = viewModel.getViewLineRenderingData(
new Range(1, 1, 1, 1),
1
).inlineDecorations;
assert.deepEqual(inlineDecorations, [
{
range: new Range(1, 1, 1, 1),
inlineClassName: 'before1',
type: InlineDecorationType.Before
},
{
range: new Range(1, 1, 1, 1),
inlineClassName: 'after1',
type: InlineDecorationType.After
}
]);
});
});
示例3: test
test('issue #17208: Problem scrolling in 1.8.0', () => {
const text = [
'hello world, this is a buffer that will be wrapped'
];
const opts: MockCodeEditorCreationOptions = {
wordWrap: 'wordWrapColumn',
wordWrapColumn: 13
};
testViewModel(text, opts, (viewModel, model) => {
assert.equal(viewModel.getLineContent(1), 'hello world, ');
assert.equal(viewModel.getLineContent(2), 'this is a ');
assert.equal(viewModel.getLineContent(3), 'buffer that ');
assert.equal(viewModel.getLineContent(4), 'will be ');
assert.equal(viewModel.getLineContent(5), 'wrapped');
let dec1: string;
model.changeDecorations((accessor) => {
dec1 = accessor.addDecoration(
new Range(1, 50, 1, 51),
{
beforeContentClassName: 'dec1'
}
);
});
let decorations = viewModel.getDecorationsInViewport(
new Range(2, viewModel.getLineMinColumn(2), 3, viewModel.getLineMaxColumn(3))
);
assert.deepEqual(decorations, []);
let inlineDecorations1 = viewModel.getViewLineRenderingData(
new Range(2, viewModel.getLineMinColumn(2), 3, viewModel.getLineMaxColumn(3)),
2
).inlineDecorations;
assert.deepEqual(inlineDecorations1, []);
let inlineDecorations2 = viewModel.getViewLineRenderingData(
new Range(2, viewModel.getLineMinColumn(2), 3, viewModel.getLineMaxColumn(3)),
3
).inlineDecorations;
assert.deepEqual(inlineDecorations2, []);
});
});
示例4: assertGetPlainTextToCopy
function assertGetPlainTextToCopy(text: string[], ranges: Range[], emptySelectionClipboard: boolean, expected: string | string[]): void {
testViewModel(text, {}, (viewModel, model) => {
let actual = viewModel.getPlainTextToCopy(ranges, emptySelectionClipboard, false);
assert.deepEqual(actual, expected);
});
}
示例5: test
test('getDecorationsViewportData', () => {
const text = [
'hello world, this is a buffer that will be wrapped'
];
const opts: editorCommon.ICodeEditorWidgetCreationOptions = {
wordWrap: 'wordWrapColumn',
wordWrapColumn: 13
};
testViewModel(text, opts, (viewModel, model) => {
assert.equal(viewModel.getLineContent(1), 'hello world, ');
assert.equal(viewModel.getLineContent(2), 'this is a ');
assert.equal(viewModel.getLineContent(3), 'buffer that ');
assert.equal(viewModel.getLineContent(4), 'will be ');
assert.equal(viewModel.getLineContent(5), 'wrapped');
let dec1: string;
let dec2: string;
let dec3: string;
let dec4: string;
let dec5: string;
let dec6: string;
let dec7: string;
let dec8: string;
let dec9: string;
let dec10: string;
let dec11: string;
let dec12: string;
let dec13: string;
let dec14: string;
let dec15: string;
model.changeDecorations((accessor) => {
let createOpts = (id: string) => {
return {
className: id,
inlineClassName: 'i-' + id,
beforeContentClassName: 'b-' + id,
afterContentClassName: 'a-' + id
};
};
// VIEWPORT will be (1,14) -> (1,36)
// completely before viewport
dec1 = accessor.addDecoration(new Range(1, 2, 1, 3), createOpts('dec1'));
// starts before viewport, ends at viewport start
dec2 = accessor.addDecoration(new Range(1, 2, 1, 14), createOpts('dec2'));
// starts before viewport, ends inside viewport
dec3 = accessor.addDecoration(new Range(1, 2, 1, 15), createOpts('dec3'));
// starts before viewport, ends at viewport end
dec4 = accessor.addDecoration(new Range(1, 2, 1, 36), createOpts('dec4'));
// starts before viewport, ends after viewport
dec5 = accessor.addDecoration(new Range(1, 2, 1, 51), createOpts('dec5'));
// starts at viewport start, ends at viewport start
dec6 = accessor.addDecoration(new Range(1, 14, 1, 14), createOpts('dec6'));
// starts at viewport start, ends inside viewport
dec7 = accessor.addDecoration(new Range(1, 14, 1, 16), createOpts('dec7'));
// starts at viewport start, ends at viewport end
dec8 = accessor.addDecoration(new Range(1, 14, 1, 36), createOpts('dec8'));
// starts at viewport start, ends after viewport
dec9 = accessor.addDecoration(new Range(1, 14, 1, 51), createOpts('dec9'));
// starts inside viewport, ends inside viewport
dec10 = accessor.addDecoration(new Range(1, 16, 1, 18), createOpts('dec10'));
// starts inside viewport, ends at viewport end
dec11 = accessor.addDecoration(new Range(1, 16, 1, 36), createOpts('dec11'));
// starts inside viewport, ends after viewport
dec12 = accessor.addDecoration(new Range(1, 16, 1, 51), createOpts('dec12'));
// starts at viewport end, ends at viewport end
dec13 = accessor.addDecoration(new Range(1, 36, 1, 36), createOpts('dec13'));
// starts at viewport end, ends after viewport
dec14 = accessor.addDecoration(new Range(1, 36, 1, 51), createOpts('dec14'));
// starts after viewport, ends after viewport
dec15 = accessor.addDecoration(new Range(1, 40, 1, 51), createOpts('dec15'));
});
let actualDecorations = viewModel.getDecorationsInViewport(
new Range(2, viewModel.getLineMinColumn(2), 3, viewModel.getLineMaxColumn(3))
).map((dec) => {
return dec.source.id;
});
assert.deepEqual(actualDecorations, [
dec2,
dec3,
dec4,
dec5,
dec6,
dec7,
dec8,
dec9,
dec10,
dec11,
dec12,
dec13,
dec14,
]);
//.........這裏部分代碼省略.........