Skip to content

Commit

Permalink
v1.8.0 - tidied and linted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robole committed May 4, 2023
1 parent f9b633c commit 9ef0ad4
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 51 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/-0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.8.0] - 2023-04-20

### Added

- Added badges for downloads and installs to README.

### Changed

- Improved test cases in *extension.test.js*.
- Linted test files.

### Removed

- Removed FAQ about file icons from README. Made into a GitHub issue instead.

## [1.7.0] - 2023-04-20

### Added
Expand Down
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
<img src="https://img.shields.io/visual-studio-marketplace/v/robole.file-bunny?logo=visual-studio-code&color=ffa500" alt="Visual Studio Marketplace Version">
<img src="https://img.shields.io/static/v1?logo=visual-studio-code&label=size&message=52KB&color=008000"
alt="Extension file size in bytes">
<img src="https://img.shields.io/visual-studio-marketplace/r/robole.file-bunny?logo=visual-studio-code&color=yellow" alt="Visual Studio Marketplace Rating">
<img src="https://img.shields.io/visual-studio-marketplace/r/robole.file-bunny?logo=visual-studio-code&color=ffd54c" alt="Visual Studio Marketplace Rating">
<img src="https://img.shields.io/visual-studio-marketplace/d/robole.file-bunny?logo=visual-studio-code&color=blue" alt="downloads"/>
<img src="https://img.shields.io/visual-studio-marketplace/i/robole.file-bunny?logo=visual-studio-code&color=blue" alt="installs"/>
<img src="https://img.shields.io/static/v1?label=built%20with&message=carrot%20juice%20%26%20javascript&color=orange" alt="Built with carrot juice and javascript"/>
<a href="https://ko-fi.com/roboleary"><img src="https://img.shields.io/badge/Buy%20me%20a%20coffee-$4-orange?logo=buy-me-a-coffee" alt="Buy me a coffee"></a>
<a href="https://ko-fi.com/roboleary"><img src="https://img.shields.io/badge/Buy%20me%20a%20coffee-$4-yellow?logo=buy-me-a-coffee&label=Buy%20me%20a%20coffee&color=ffc300" alt="Buy me a coffee"></a>
</p>

No need to *hop* to the Sidebar to work with files. 😜
Expand Down Expand Up @@ -158,7 +160,7 @@ If you want to contribute to the development, please discuss it with me first! I

You can show your appreciation by:
1. [Buying me a coffee or sponsoring me](https://ko-fi.com/roboleary)
1. Leaving a positive review in the [visual studio marketplace](<https://marketplace.visualstudio.com/items?itemName=robole.marky-stats&ssr=false#review-details>).
1. Leaving a positive review in the [visual studio marketplace](<https://marketplace.visualstudio.com/items?itemName=robole.file-bunny&ssr=false#review-details>).
1. Starring the repo 🌟.

This will **help other people find the extension**.
Expand All @@ -175,7 +177,7 @@ No. I don't use multi-root workspaces, so I have not implemented this feature. I

### 2) Why can't I delete an image and some non-code files with the command `File Bunny: Delete Active File` ?

This is a current limitation of VS Code. When you open an image in VS Code, the tab cannot be referenced through the Extensions API. There is an [open issue](https://github.com/microsoft/vscode/issues/15178) to change this. When [if] this change happens, I can update the extension to incorporate this behaviour.
This is a current limitation of VS Code. When you open an image in VS Code, the tab cannot be referenced through the Extensions API. There is an [open issue in the VS Code repo](https://github.com/microsoft/vscode/issues/15178) to change this. I have [an issue for this](https://github.com/robole/vscode-file-bunny/issues/4) and will change if/when Microsoft add this feature.

### 3) When I run the command `File Bunny: Open Folder` on Windows, I see extra folders at *C:*. What's the deal with that?

Expand All @@ -188,11 +190,3 @@ These are hidden system folders such as the recycle bin. You don't see these in
The reason this extension shows them is because it uses [node glob](https://www.npmjs.com/package/glob) under the hood, and glob dutifully reports these back as folders. If you open them, you can't do anything with them because of permissions.

This is not something I can turn off, it is just a quirk with Windows and glob. If it bothers you, add the specific folders to the `Filebunny: Excludes` setting, so that you won't see them in future.

### 4) Can you use the language file icons in the Quickpick instead of the generic file or folder icon?

Currently, it is only possible to use [product icons](https://code.visualstudio.com/api/references/icons-in-labels) in the label of a [QuickPickItem](https://code.visualstudio.com/api/references/vscode-api#QuickPickItem).

Product icons are the built-in icons that are used throughout the editor. The product icons that ship with VS Code are contained in the [Codicon icon font](https://github.com/microsoft/vscode-codicons) and form the default product icon theme. I use the *file*, *symbolic link*, and *folder* icons from this font in the labels.

There is an [open issue for adding support for file icons to the QuickPick API](https://github.com/microsoft/vscode/issues/59826). File icons are used next to file names in the UI, and are defined in a [file icon theme](https://code.visualstudio.com/api/extension-guides/file-icon-theme).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"description": "Perform file actions quickly with keyboard-driven file selection. 🐰⌨️",
"icon": "img/logo.png",
"version": "1.7.0",
"version": "1.8.0",
"engines": {
"vscode": "^1.46.0",
"node": ">=12"
Expand Down
41 changes: 27 additions & 14 deletions test/suite/extension.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,44 @@ const assert = require("assert");

describe("extension", () => {
const extensionShortName = "file-bunny";
const extensionID = `robole.${extensionShortName}`;
const publisherName = "robole";
const extensionID = `${publisherName}.${extensionShortName}`;

let extension;

before(() => {
extension = vscode.extensions.getExtension(extensionID);
});

it("All commands in the package.json should be registered in extension", (done) => {
const packageCommands = extension.packageJSON.contributes.commands.map(
(c) => c.command
);
it("should activate the extension on startup", async () => {
// we delay 1 second to give the extension time to load
setTimeout(async () => {
assert.strictEqual(extension.isActive, true);
});
});

// get all extension commands excluding internal commands.
vscode.commands.getCommands(true).then((allCommands) => {
const activeCommands = allCommands.filter((c) =>
it("should register all package.json commands in the extension", async () => {
// we delay 1 second to give the extension time to load
setTimeout(async () => {
// get active commands for this extension
const allCommands = await vscode.commands.getCommands(true);
const extensionActiveCommands = allCommands.filter((c) =>
c.startsWith(`${extensionShortName}.`)
);

activeCommands.forEach((command) => {
const result = packageCommands.some((c) => c === command);
assert.ok(result);
});
// commands declared in package.json
const packageCommands = extension.packageJSON.contributes.commands.map(
(c) => c.command
);

done();
});
packageCommands.forEach((command) => {
const result = extensionActiveCommands.some((c) => c === command);
assert.strictEqual(
result,
true,
`${command} command is in package.json but not registered in extension.`
);
});
}, 1000);
});
});
2 changes: 1 addition & 1 deletion test/suite/fileSystem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let assert = require("assert");
const path = require("path");
const fileSystem = require("../../src/fileSystem");

describe("fileSystem", function () {
describe("fileSystem", () => {
describe("exists()", () => {
let testFile = path.join(__dirname, "..", "..", "test", "test.md");
let testFileUri = vscode.Uri.file(testFile);
Expand Down
9 changes: 4 additions & 5 deletions test/suite/globPicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require("path");
const globPicker = require("../../src/globPicker");
const FileType = require("../../src/fileType");

describe("globPicker", function () {
describe("globPicker", () => {
describe("getFilesRecursivelyAsPickerItems()", () => {
let projectRoot = path.join(__dirname, "..", "..");

Expand Down Expand Up @@ -532,12 +532,12 @@ describe("globPicker", function () {
});

it("should return the files for the root folder ", async () => {
let root ="/";
let root = "/";

if(process.platform === 'win32'){
if (process.platform === "win32") {
root = "C:\\";
}

let files = await globPicker.getFilesAsPickerItems(root, {
showFiles: false,
showFolders: true,
Expand All @@ -550,6 +550,5 @@ describe("globPicker", function () {

assert.strictEqual(files.length > 1, true);
});

});
});
25 changes: 12 additions & 13 deletions test/suite/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const vscode = require("vscode");
let assert = require("assert");
const util = require("../../src/util");

describe("util", function () {
describe("util", () => {
describe("escapePath()", () => {
it("should return escaped path", () => {
const expected = "C:/Program Files \\(x86\\)";
Expand All @@ -16,37 +16,37 @@ describe("util", function () {

describe("isRootFolder()", () => {
it("should return true if the folder has no parent folder in Windows", () => {
if(process.platform === 'win32'){
if (process.platform === "win32") {
const winRoot = util.isRootFolder("C:\\");
assert.strictEqual(winRoot, true);
}
});

it("should return true if the folder is C:/ in Windows", () => {
if(process.platform === 'win32'){
if (process.platform === "win32") {
const winRoot = util.isRootFolder("C:/");
assert.strictEqual(winRoot, true);
}
});

it("should return true if the folder has no parent folder in Linux", () => {
if(process.platform !== 'win32'){
const linuxRoot = util.isRootFolder("/");
assert.strictEqual(linuxRoot, true);
if (process.platform !== "win32") {
const linuxRoot = util.isRootFolder("/");
assert.strictEqual(linuxRoot, true);
}
});

it("should return false if the folder has no parent folder in Windows", () => {
if(process.platform === 'win32'){
const winNotRoot = util.isRootFolder("C:\\Program Files (x86)");
assert.strictEqual(winNotRoot, false);
if (process.platform === "win32") {
const winNotRoot = util.isRootFolder("C:\\Program Files (x86)");
assert.strictEqual(winNotRoot, false);
}
});

it("should return false if the folder has no parent folder in Linux", () => {
if(process.platform !== 'win32'){
const linuxNotRoot = util.isRootFolder("/home");
assert.strictEqual(linuxNotRoot, false);
if (process.platform !== "win32") {
const linuxNotRoot = util.isRootFolder("/home");
assert.strictEqual(linuxNotRoot, false);
}
});
});
Expand Down Expand Up @@ -84,5 +84,4 @@ describe("util", function () {
);
});
});

});
5 changes: 0 additions & 5 deletions todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
1. `File Bunny: New Project from Template`?
1. Add multi-root workspace support?

## Long-standing Extension API issues

- Cannot delete active file if it is image. No way to reference active editor. Awaiting change from this [open issue](https://github.com/microsoft/vscode/issues/15178).
- There is an [open issue for adding support for file icons to the QuickPick API](https://github.com/microsoft/vscode/issues/59826).

## Further ideas

1. Use different fuzzy search algo?
Expand Down

0 comments on commit 9ef0ad4

Please sign in to comment.