|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import * as assert from 'assert'; |
| 7 | +import { Event } from 'vs/base/common/event'; |
| 8 | +import { Disposable } from 'vs/base/common/lifecycle'; |
| 9 | +import { isEqual } from 'vs/base/common/resources'; |
| 10 | +import { URI } from 'vs/base/common/uri'; |
| 11 | +import { mock } from 'vs/base/test/common/mock'; |
| 12 | +import { IFileService } from 'vs/platform/files/common/files'; |
| 13 | +import { ILabelService } from 'vs/platform/label/common/label'; |
| 14 | +import { NullLogService } from 'vs/platform/log/common/log'; |
| 15 | +import { INotificationService } from 'vs/platform/notification/common/notification'; |
| 16 | +import { NotebookEditorModel } from 'vs/workbench/contrib/notebook/common/notebookEditorModel'; |
| 17 | +import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService'; |
| 18 | +import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; |
| 19 | +import { IWorkingCopy, IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService'; |
| 20 | + |
| 21 | +suite('NotebookEditorModel', function () { |
| 22 | + |
| 23 | + const notebokService = new class extends mock<INotebookService>() { }; |
| 24 | + const backupService = new class extends mock<IBackupFileService>() { }; |
| 25 | + const notificationService = new class extends mock<INotificationService>() { }; |
| 26 | + const fileService = new class extends mock<IFileService>() { |
| 27 | + onDidFilesChange = Event.None; |
| 28 | + }; |
| 29 | + const labelService = new class extends mock<ILabelService>() { |
| 30 | + getUriBasenameLabel(uri: URI) { return uri.toString(); } |
| 31 | + }; |
| 32 | + |
| 33 | + test('working copy uri', function () { |
| 34 | + if (1) { |
| 35 | + this.skip(); |
| 36 | + } |
| 37 | + const r1 = URI.parse('foo-files:///my.nb'); |
| 38 | + const r2 = URI.parse('bar-files:///my.nb'); |
| 39 | + |
| 40 | + const copies: IWorkingCopy[] = []; |
| 41 | + const workingCopyService = new class extends mock<IWorkingCopyService>() { |
| 42 | + registerWorkingCopy(copy: IWorkingCopy) { |
| 43 | + copies.push(copy); |
| 44 | + return Disposable.None; |
| 45 | + } |
| 46 | + }; |
| 47 | + |
| 48 | + new NotebookEditorModel(r1, 'fff', notebokService, workingCopyService, backupService, fileService, notificationService, new NullLogService(), labelService); |
| 49 | + new NotebookEditorModel(r2, 'fff', notebokService, workingCopyService, backupService, fileService, notificationService, new NullLogService(), labelService); |
| 50 | + |
| 51 | + assert.strictEqual(copies.length, 2); |
| 52 | + assert.strictEqual(!isEqual(copies[0].resource, copies[1].resource), true); |
| 53 | + }); |
| 54 | +}); |
0 commit comments