window.test.ts 1.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import * as assert from 'assert';
9
import {workspace, window, ViewColumn} from 'vscode';
B
Benjamin Pasero 已提交
10
import {join} from 'path';
11
import {cleanUp, pathEquals} from './utils';
E
Erich Gamma 已提交
12

B
Benjamin Pasero 已提交
13
suite("window namespace tests", () => {
E
Erich Gamma 已提交
14

15
	teardown(cleanUp);
16

17
	test('editor, active text editor', () => {
18
		return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
B
Benjamin Pasero 已提交
19 20 21
			return window.showTextDocument(doc).then((editor) => {
				const active = window.activeTextEditor;
				assert.ok(active);
22
				assert.ok(pathEquals(active.document.uri.fsPath, doc.uri.fsPath));
B
Benjamin Pasero 已提交
23
			});
24
		});
B
Benjamin Pasero 已提交
25
	});
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

	test('editor, assign and check view columns', () => {

		return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
			let p1 = window.showTextDocument(doc, ViewColumn.One).then(editor => {
				assert.equal(editor.viewColumn, ViewColumn.One);
			});
			let p2 = window.showTextDocument(doc, ViewColumn.Two).then(editor => {
				assert.equal(editor.viewColumn, ViewColumn.Two);
			});
			let p3 = window.showTextDocument(doc, ViewColumn.Three).then(editor => {
				assert.equal(editor.viewColumn, ViewColumn.Three);
			});
			return Promise.all([p1, p2, p3]);
		});
	});
E
Erich Gamma 已提交
42
});