mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-25 17:27:26 +01:00
editor model - add some tests
This commit is contained in:
@@ -835,6 +835,9 @@ export class EditorModel extends Disposable implements IEditorModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if this model has been disposed.
|
||||
*/
|
||||
isDisposed(): boolean {
|
||||
return this.disposed;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as assert from 'assert';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { EncodingMode } from 'vs/workbench/common/editor';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { TextFileEditorModelState, snapshotToString } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { TextFileEditorModelState, snapshotToString, isTextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { createFileEditorInput, workbenchInstantiationService, TestServiceAccessor, TestReadonlyTextFileEditorModel } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { toResource } from 'vs/base/test/common/utils';
|
||||
import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager';
|
||||
@@ -73,6 +73,14 @@ suite('Files - TextFileEditorModel', () => {
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('isTextFileEditorModel', async function () {
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/index_async.txt'), 'utf8', undefined);
|
||||
|
||||
assert.equal(isTextFileEditorModel(model), true);
|
||||
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('save', async function () {
|
||||
const model: TextFileEditorModel = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/index_async.txt'), 'utf8', undefined);
|
||||
|
||||
|
||||
@@ -60,9 +60,11 @@ suite('Workbench editor model', () => {
|
||||
|
||||
const model = await m.load();
|
||||
assert(model === m);
|
||||
assert.equal(model.isDisposed(), false);
|
||||
assert.strictEqual(m.isResolved(), true);
|
||||
m.dispose();
|
||||
assert.equal(counter, 1);
|
||||
assert.equal(model.isDisposed(), true);
|
||||
});
|
||||
|
||||
test('BaseTextEditorModel', async () => {
|
||||
|
||||
Reference in New Issue
Block a user