mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MainThreadDocumentContentProviders } from 'vs/workbench/api/browser/mainThreadDocumentContentProviders';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { mock } from 'vs/workbench/test/browser/api/mock';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
|
||||
import { TextEdit } from 'vs/editor/common/modes';
|
||||
|
||||
suite('MainThreadDocumentContentProviders', function () {
|
||||
|
||||
test('events are processed properly', function () {
|
||||
|
||||
let uri = URI.parse('test:uri');
|
||||
let model = TextModel.createFromString('1', undefined, undefined, uri);
|
||||
|
||||
let providers = new MainThreadDocumentContentProviders(new TestRPCProtocol(), null!, null!,
|
||||
new class extends mock<IModelService>() {
|
||||
getModel(_uri: URI) {
|
||||
assert.equal(uri.toString(), _uri.toString());
|
||||
return model;
|
||||
}
|
||||
},
|
||||
new class extends mock<IEditorWorkerService>() {
|
||||
computeMoreMinimalEdits(_uri: URI, data: TextEdit[] | undefined) {
|
||||
assert.equal(model.getValue(), '1');
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let expectedEvents = 1;
|
||||
model.onDidChangeContent(e => {
|
||||
expectedEvents -= 1;
|
||||
try {
|
||||
assert.ok(expectedEvents >= 0);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
if (model.getValue() === '1\n2\n3') {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
providers.$onVirtualDocumentChange(uri, '1\n2');
|
||||
providers.$onVirtualDocumentChange(uri, '1\n2\n3');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user