Skip to content

Commit

Permalink
Merge pull request #3 from yamajyn/feature/promise-test
Browse files Browse the repository at this point in the history
Primsieを返す関数のテストコードを修正
  • Loading branch information
yamajyn authored Jul 10, 2019
2 parents 934807a + f3478b3 commit 6775697
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 28 deletions.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
![GitHub release](https://img.shields.io/github/release/yamajyn/commandlist.svg?style=flat)
![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)

![commandlist](resources/dark/icon.svg)
![commandlist](resources/light/icon.svg)
![commandlist](resources/icon@64.svg)

Run and Save commands in WorkSpace or Global

Expand All @@ -17,23 +16,21 @@ Run and Save commands in WorkSpace or Global

## Extension Settings

Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.

For example:

This extension contributes the following settings:

* `myExtension.enable`: enable/disable this extension
* `myExtension.thing`: set to `blah` to do something
* `commandList.enable`: enable/disable this extension

## Release Notes

Users appreciate release notes as you update your extension.

### 1.0.0

Initial release of commandlist

### 0.1.0

create Command explorer and command executer.

-----------------------------------------------------------------------------------------------------------

## Changelog
Expand Down
19 changes: 19 additions & 0 deletions resources/icon@64.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/commandExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ export class FileSystemProvider implements vscode.TreeDataProvider<Entry>, vscod
return { dispose: () => watcher.close() };
}

stat(uri: vscode.Uri): vscode.FileStat | Thenable<vscode.FileStat> {
stat(uri: vscode.Uri): Thenable<vscode.FileStat> {
return this._stat(uri.fsPath);
}

async _stat(path: string): Promise<vscode.FileStat> {
return new FileStat(await _.stat(path));
}

readDirectory(uri: vscode.Uri): [string, vscode.FileType][] | Thenable<[string, vscode.FileType][]> {
readDirectory(uri: vscode.Uri): Thenable<[string, vscode.FileType][]> {
return this._readDirectory(uri);
}

Expand All @@ -245,15 +245,15 @@ export class FileSystemProvider implements vscode.TreeDataProvider<Entry>, vscod
return Promise.resolve(result);
}

createDirectory(uri: vscode.Uri): void | Thenable<void> {
createDirectory(uri: vscode.Uri): Thenable<void> {
return _.mkdir(uri.fsPath);
}

readFile(uri: vscode.Uri): Promise<Uint8Array> {
return _.readfile(uri.fsPath);
}

writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean; }): void | Thenable<void> {
writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean; }): Thenable<void> {
return this._writeFile(uri.fsPath, content, options);
}

Expand All @@ -278,15 +278,15 @@ export class FileSystemProvider implements vscode.TreeDataProvider<Entry>, vscod
return Uint8Array.from(Buffer.from(s));
}

delete(uri: vscode.Uri, options: { recursive: boolean; }): void | Thenable<void> {
delete(uri: vscode.Uri, options: { recursive: boolean; }): Thenable<void> {
if (options.recursive) {
return _.rmrf(uri.fsPath);
}

return _.unlink(uri.fsPath);
}

rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean; }): void | Thenable<void> {
rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean; }): Thenable<void> {
return this._rename(oldUri, newUri, options);
}

Expand Down
30 changes: 17 additions & 13 deletions src/test/commandExplorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ export const commandExplorerTest = () => {

const dir = vscode.Uri.file(__dirname + "/testdir");
test("createDirectory", () => {
provider.createDirectory(dir);
provider.isExists(dir.fsPath).then(result => {
assert.equal(true, result);
});
return provider.createDirectory(dir).then(_ => {
return provider.isExists(dir.fsPath);
}).then(result => {
assert.equal(true, result);
});

});

const file = vscode.Uri.file(__dirname + "/testdir/test.json");
const testJSON: Command = {
script: "ls -a"
script: 'ls -a'
};
test("writeFile", () => {
const content = provider.stringToUnit8Array(JSON.stringify(testJSON));
assert.ok(provider.writeFile(file, content, { create: true, overwrite: true }));
});

test('isExists', () => {
provider.isExists(file.fsPath).then(result => {
return provider.writeFile(file, content, { create: true, overwrite: true }).then(_ => {
return provider.isExists(file.fsPath);
}).then(result => {
assert.equal(true, result);
});
});

test('readFile', () => {
provider.readFile(file).then(result => {
assert.equal(testJSON, result.toString());
return provider.readFile(file).then(result => {
assert.equal(JSON.stringify(testJSON), result.toString());
});
});

Expand All @@ -45,7 +45,11 @@ export const commandExplorerTest = () => {
});

test('deleteFile', () => {
provider.delete(dir, { recursive : true });
return provider.delete(dir, { recursive : true }).then( _ => {
return provider.isExists(file.fsPath);
}).then(result => {
assert.equal(false, result);
});
});
});
};

0 comments on commit 6775697

Please sign in to comment.