提交 052a1dc8 编写于 作者: B Benjamin Pasero

api tests - more use of promises in mocha

上级 f924875c
......@@ -14,12 +14,10 @@ import {join} from 'path';
suite("editor tests", () => {
teardown((done) => {
cleanUp().then(() => done(), (error) => done(error));
});
teardown(cleanUp);
test('make edit', (done) => {
createRandomFile().then(file => {
test('make edit', () => {
return createRandomFile().then(file => {
return workspace.openTextDocument(file).then(doc => {
return window.showTextDocument(doc).then((editor) => {
return editor.edit((builder) => {
......@@ -38,6 +36,6 @@ suite("editor tests", () => {
});
});
});
}).then(() => done(), (error) => done(error));
});
});
});
\ No newline at end of file
......@@ -12,17 +12,15 @@ import {cleanUp} from './utils';
suite("window namespace tests", () => {
teardown((done) => {
cleanUp().then(() => done(), (error) => done(error));
});
teardown(cleanUp);
test('active text editor', (done) => {
workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
test('active text editor', () => {
return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
return window.showTextDocument(doc).then((editor) => {
const active = window.activeTextEditor;
assert.ok(active);
assert.equal(active.document.uri.fsPath, doc.uri.fsPath);
});
}).then(() => done(), (error) => done(error));
});
});
});
\ No newline at end of file
......@@ -40,8 +40,8 @@ suite('workspace-namespace', () => {
});
});
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', (done) => {
createRandomFile().then(file => {
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
return createRandomFile().then(file => {
let disposables = [];
let onDidOpenTextDocument = false;
......@@ -81,17 +81,13 @@ suite('workspace-namespace', () => {
});
});
});
}).then(() => done(), (error) => done(error));
});
});
test('findFiles', done => {
workspace.findFiles('*.js', null).then((res) => {
test('findFiles', () => {
return workspace.findFiles('*.js', null).then((res) => {
assert.equal(res.length, 1);
assert.equal(workspace.asRelativePath(res[0]), '/far.js');
done();
}, err => {
done(err);
});
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册