Skip to content

Commit

Permalink
test(fs-tree-structure): migrate to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-coulon committed May 27, 2024
1 parent fbe7eed commit 5ab375c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 465 deletions.
16 changes: 8 additions & 8 deletions packages/fs-tree-structure/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect } from "chai";
import { expect, describe, test } from "vitest";

import { makeTreeStructure } from "./index.js";

describe("Filesystem tree structure maker", () => {
describe("When dealing with absolute paths", () => {
describe("When there is one file with no base directory", () => {
it("should make a flat tree structure", () => {
test("should make a flat tree structure", () => {
const filePaths = ["index.js"];

expect(makeTreeStructure(filePaths)).to.deep.equal({
Expand All @@ -15,7 +15,7 @@ describe("Filesystem tree structure maker", () => {
});

describe("When files are not located in the same parent directories", () => {
it("should make a tree structure from raw file paths", () => {
test("should make a tree structure from raw file paths", () => {
const filePaths = ["lib/feature/index.js", "apps/main.js"];

expect(makeTreeStructure(filePaths)).to.deep.equal({
Expand All @@ -32,7 +32,7 @@ describe("Filesystem tree structure maker", () => {
});

describe("When files are located in the same exact parent directories", () => {
it("should make a tree structure with common parents", () => {
test("should make a tree structure with common parents", () => {
const filePaths = ["lib/feature/index.js", "lib/feature/util.js"];

expect(makeTreeStructure(filePaths)).to.deep.equal({
Expand All @@ -47,7 +47,7 @@ describe("Filesystem tree structure maker", () => {
});

describe("When files are only sharing a subset of parent directories", () => {
it("should nest them in the same leaves until they diverge", () => {
test("should nest them in the same leaves until they diverge", () => {
const filePaths = ["lib/feature/index.js", "lib/feature/util/index.js"];

expect(makeTreeStructure(filePaths)).to.deep.equal({
Expand All @@ -66,7 +66,7 @@ describe("Filesystem tree structure maker", () => {

describe("When dealing with base directory names", () => {
describe("When the directory name is the current working directory", () => {
it("should trim the base directory segment", () => {
test("should trim the base directory segment", () => {
const filePaths = [
"./lib/feature/index.js",
"lib/util.js",
Expand All @@ -93,7 +93,7 @@ describe("Filesystem tree structure maker", () => {
});

describe("When using the default sorting by files and folders", () => {
it("should sort folders before files", () => {
test("should sort folders before files", () => {
const filePaths = [
"./test/feature.js",
"./index.js",
Expand All @@ -107,7 +107,7 @@ describe("Filesystem tree structure maker", () => {
).to.deep.equal(["sub-module", "test", "index.js", "main.js", "root.js"]);
});

it("should sort folders before files", () => {
test("should sort folders before files", () => {
const filePaths = [
"./test/feature.js",
"./feature/some-module/index.js",
Expand Down
9 changes: 3 additions & 6 deletions packages/fs-tree-structure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prepublishOnly": "npm run test && npm run build",
"start": "node dist/bin/cli.js",
"build": "rimraf ./dist && tsc --project tsconfig.build.json",
"test": "mocha --parallel",
"test": "vitest run",
"lint": "eslint ."
},
"dependencies": {
Expand All @@ -27,17 +27,14 @@
"devDependencies": {
"@nodesecure/eslint-config": "^1.7.0",
"@skottorg/config": "workspace:*",
"@types/chai": "^4.3.5",
"@types/lodash-es": "^4.17.12",
"@types/mocha": "^9.1.1",
"@types/node": "^16.18.36",
"chai": "^4.3.7",
"@types/node": "^20.11.24",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^5.0.0",
"mocha": "^9.2.2",
"vitest": "1.6.0",
"prettier": "^3.0.3",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/remote-tarball-fetcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"prestart": "npm run build",
"prepublishOnly": "npm run build",
"build": "rimraf ./dist && tsc --project tsconfig.build.json",
"test": "vitest",
"test": "vitest run",
"lint": "eslint ."
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/skott/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@types/compression": "^1.7.2",
"@types/ignore-walk": "^4.0.0",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.8.2",
"@types/node": "^20.11.24",
"@types/polka": "^0.5.4",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
Expand Down
Loading

0 comments on commit 5ab375c

Please sign in to comment.