Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-api-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-api-js - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

8

package.json
{
"name": "fs-api-js",
"version": "0.1.0",
"version": "0.2.0",
"main": "src/main.js",

@@ -13,2 +13,3 @@ "repository": "https://github.com/sourcelair/fs-api-js",

"prettier": "^1.13.7",
"prettier-check": "^2.0.0",
"watchify": "^3.11.0"

@@ -18,6 +19,7 @@ },

"test": "jest",
"format": "prettier \"src/*.js\" --write",
"format": "prettier src/*.js --write",
"watch": "watchify src/main.js --verbose --standalone fsApi -o dist/fsapi.js",
"start": "browser-sync start --server --watch --files 'dist/*' 'index.html' --port $PORT"
"start": "browser-sync start --server --watch --files 'dist/*' 'index.html' --port $PORT",
"lint": "prettier-check src/*.js"
}
}

@@ -5,3 +5,10 @@ function convertItemsToUnorderedList(listItems) {

const liElement = document.createElement("li");
liElement.textContent = item.name;
liElement.classList.add("fs-api-entry", `fs-api-${item.type}`);
const nameElement = document.createElement("span");
nameElement.textContent = item.name;
nameElement.classList.add("fs-api-entry-name");
liElement.appendChild(nameElement);
if (item.children) {
renderInput(item.children, liElement);
}
ulElement.appendChild(liElement);

@@ -20,3 +27,3 @@ });

const dirItems = input.filter(inputEl => inputEl.type === "directory"),
fileItems = input.filter(inputEl => inputEl.type === "file");
fileItems = input.filter(inputEl => inputEl.type === "file");
dirItems.sort(alphabeticCompare);

@@ -26,5 +33,6 @@ fileItems.sort(alphabeticCompare);

ulElement = convertItemsToUnorderedList(listItems);
ulElement.classList.add("fs-api-tree");
container.appendChild(ulElement);
}
module.exports.render = renderInput;
module.exports.render = renderInput;

@@ -39,3 +39,16 @@ const fsapi = require("./main");

type: "directory",
children: null
children: [
{
name: "yarn.lock",
absolute_path: "/mnt/project/vendor/yarn.lock",
type: "file",
children: null
},
{
name: "package.json",
absolute_path: "/mnt/project/vendor/package.json",
type: "file",
children: null
}
]
}

@@ -46,13 +59,38 @@ ];

const ul = container.querySelector("ul");
for (const child of ul.children) {
const trees = container.querySelectorAll("ul");
const rootTree = trees[0];
for (const child of rootTree.children) {
expect(child).toBeInstanceOf(HTMLLIElement);
}
expect(ul.children[0].textContent).toBe("Dir");
expect(ul.children[1].textContent).toBe("FinalDir");
expect(ul.children[2].textContent).toBe("AnotherFile.html");
expect(ul.children[3].textContent).toBe("SFile.sth");
expect(ul.children[4].textContent).toBe("test.go");
expect(ul.children[5].textContent).toBe("Troll.go");
expect(rootTree.children[0].children[0].textContent).toBe("Dir");
expect(rootTree.children[1].children[0].textContent).toBe("FinalDir");
expect(rootTree.children[2].children[0].textContent).toBe("AnotherFile.html");
expect(rootTree.children[3].children[0].textContent).toBe("SFile.sth");
expect(rootTree.children[4].children[0].textContent).toBe("test.go");
expect(rootTree.children[5].children[0].textContent).toBe("Troll.go");
expect(trees[1].children[0].children[0].textContent).toBe("package.json");
expect(trees[1].children[1].children[0].textContent).toBe("yarn.lock");
for (const ulElement of trees) {
expect(ulElement.classList.contains("fs-api-tree")).toBe(true);
}
expect(rootTree.children[0].classList.contains("fs-api-directory")).toBe(
true
);
expect(rootTree.children[1].classList.contains("fs-api-directory")).toBe(
true
);
expect(rootTree.children[2].classList.contains("fs-api-file")).toBe(true);
expect(rootTree.children[3].classList.contains("fs-api-file")).toBe(true);
expect(rootTree.children[4].classList.contains("fs-api-file")).toBe(true);
expect(rootTree.children[5].classList.contains("fs-api-file")).toBe(true);
for (const tree of trees) {
for (const child of tree.children) {
expect(child.children[0].classList.contains("fs-api-entry-name")).toBe(
true
);
expect(child.classList.contains("fs-api-entry")).toBe(true);
}
}
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc