diff --git a/examples/api-tests/src/saveable.spec.js b/examples/api-tests/src/saveable.spec.js index cfaca9ed11c34..3214d4c8e635e 100644 --- a/examples/api-tests/src/saveable.spec.js +++ b/examples/api-tests/src/saveable.spec.js @@ -66,18 +66,20 @@ describe('Saveable', function () { const autoSave = preferences.get('editor.autoSave', undefined, rootUri.toString()); beforeEach(async () => { - preferences.set('editor.autoSave', 'off', undefined, rootUri.toString()); + await preferences.set('editor.autoSave', 'off', undefined, rootUri.toString()); await editorManager.closeAll({ save: false }); await fileService.create(fileUri, 'foo', { fromUserGesture: false, overwrite: true }); widget = /** @type {EditorWidget & SaveableWidget} */ (await editorManager.open(fileUri, { mode: 'reveal' })); - editor = MonacoEditor.get(widget); + editor = /** @type {MonacoEditor} */ (MonacoEditor.get(widget)); }); afterEach(async () => { toTearDown.dispose(); - preferences.set('editor.autoSave', autoSave, undefined, rootUri.toString()); + await preferences.set('editor.autoSave', autoSave, undefined, rootUri.toString()); + // @ts-ignore editor = undefined; + // @ts-ignore widget = undefined; await editorManager.closeAll({ save: false }); await fileService.delete(fileUri.parent, { fromUserGesture: false, useTrash: false, recursive: true }); @@ -104,6 +106,7 @@ describe('Saveable', function () { editor.getControl().setValue(longContent); await Saveable.save(widget); + // @ts-ignore editor.getControl().getModel().applyEdits([{ range: monaco.Range.fromPositions({ lineNumber: 1, column: 1 }, { lineNumber: 1, column: 4 }), forceMoveMarkers: false, @@ -113,6 +116,7 @@ describe('Saveable', function () { const resource = editor.document['resource']; const version = resource.version; + // @ts-ignore await resource.saveContents('baz'); assert.notEqual(version, resource.version, 'latest version should be different after write'); @@ -128,6 +132,7 @@ describe('Saveable', function () { const saveContentChanges = resource.saveContentChanges; resource.saveContentChanges = async (changes, options) => { incrementalUpdate = true; + // @ts-ignore return saveContentChanges.bind(resource)(changes, options); }; try { @@ -156,6 +161,7 @@ describe('Saveable', function () { const resource = editor.document['resource']; const version = resource.version; + // @ts-ignore await resource.saveContents('bazz'); assert.notEqual(version, resource.version, 'latest version should be different after write'); @@ -268,19 +274,6 @@ describe('Saveable', function () { assert.equal(state.value.trimRight(), 'bar', 'fs should be updated'); }); - it('delete file for saved', async () => { - assert.isFalse(Saveable.isDirty(widget), 'should NOT be dirty before delete'); - const waitForDisposed = new Deferred(); - const listener = editor.onDispose(() => waitForDisposed.resolve()); - try { - await fileService.delete(fileUri); - await waitForDisposed.promise; - assert.isTrue(widget.isDisposed, 'model should be disposed after delete'); - } finally { - listener.dispose(); - } - }); - it('delete and add again file for dirty', async () => { editor.getControl().setValue('bar'); assert.isTrue(Saveable.isDirty(widget), 'should be dirty before delete'); @@ -390,7 +383,7 @@ describe('Saveable', function () { widget = /** @type {EditorWidget & SaveableWidget} */ (await editorManager.open(fileUri, { mode: 'reveal' })); - editor = MonacoEditor.get(widget); + editor = /** @type {MonacoEditor} */ (MonacoEditor.get(widget)); assert.strictEqual('utf8', editor.document.getEncoding()); assert.strictEqual('foo', editor.document.getText().trimRight()); @@ -413,7 +406,7 @@ describe('Saveable', function () { widget = /** @type {EditorWidget & SaveableWidget} */ (await editorManager.open(fileUri, { mode: 'reveal' })); - editor = MonacoEditor.get(widget); + editor = /** @type {MonacoEditor} */ (MonacoEditor.get(widget)); assert.strictEqual('utf16le', editor.document.getEncoding()); assert.notEqual('foo', editor.document.getText().trimRight()); @@ -434,10 +427,23 @@ describe('Saveable', function () { widget = /** @type {EditorWidget & SaveableWidget} */ (await editorManager.open(fileUri, { mode: 'reveal' })); - editor = MonacoEditor.get(widget); + editor = /** @type {MonacoEditor} */ (MonacoEditor.get(widget)); assert.strictEqual('utf16le', editor.document.getEncoding()); assert.strictEqual('foo', editor.document.getText().trimRight()); }); + it('delete file for saved', async () => { + assert.isFalse(Saveable.isDirty(widget), 'should NOT be dirty before delete'); + const waitForDisposed = new Deferred(); + const listener = editor.onDispose(() => waitForDisposed.resolve()); + try { + await fileService.delete(fileUri); + await waitForDisposed.promise; + assert.isTrue(widget.isDisposed, 'model should be disposed after delete'); + } finally { + listener.dispose(); + } + }); + });