Skip to content

Commit

Permalink
Move all the tests into a root test folder #67
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsalem401 committed Nov 24, 2023
1 parent 4aff486 commit 70330d1
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/lib/indexFolder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { recursiveWalkDir } from "../utils/index.js";
import { FileInfo, processFile } from "./process.js";
import { recursiveWalkDir } from "./recursiveWalkDir.js";

export function indexFolder(
folderPath: string,
Expand Down
6 changes: 3 additions & 3 deletions src/tests/markdowndb.spec.ts → src/lib/markdowndb.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import knex from "knex";
import { MarkdownDB } from "../lib/markdowndb";
import { recursiveWalkDir } from "../lib/recursiveWalkDir";
import { File, MddbFile, Table } from "../lib/schema";
import { MarkdownDB } from "./markdowndb";
import { File, MddbFile, Table } from "./schema";
import { recursiveWalkDir } from "../utils";

/**
* @jest-environment node
Expand Down
2 changes: 1 addition & 1 deletion src/lib/markdowndb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
isLinkToDefined,
mapFileTagsToInsert,
getUniqueValues,
} from "./databaseUtils.js";
} from "../utils/databaseUtils.js";

const defaultFilePathToUrl = (filePath: string) => {
let url = filePath
Expand Down
2 changes: 1 addition & 1 deletion src/tests/process.spec.ts → src/lib/process.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { processFile } from "../lib/process";
import { processFile } from "./process";
import Path from "path";

describe("Can parse a file and get file info", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import crypto from "crypto";
import fs from "fs";
import path from "path";

import { parseFile } from "../utils/index.js";
import { File } from "./schema.js";
import { WikiLink, parseFile } from "./parseFile.js";
import { WikiLink } from "../utils/parseFile.js";

export interface FileInfo extends File {
tags: string[];
Expand Down
2 changes: 1 addition & 1 deletion src/tests/validate.spec.ts → src/lib/validate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { areUniqueObjectsByKey } from "../lib/validate";
import { areUniqueObjectsByKey } from "./validate";

describe("areUniqueObjectsByKey", () => {
test("should return true if all objects have unique values for the given key", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/databaseUtils.ts → src/utils/databaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
MddbLink,
MddbFileTag,
File,
} from "./schema.js";
} from "../lib/schema.js";
import path from "path";
import { WikiLink } from "./parseFile.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extractTagsFromBody, processAST } from "../lib/parseFile";
import { extractTagsFromBody, processAST } from "./parseFile";

const getTagsFromSource = (source: string) => {
const ast = processAST(source, {});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extractWikiLinks, processAST } from "../lib/parseFile";
import { extractWikiLinks, processAST } from "./parseFile";

// TODO test for links with headings and aliases ?
// TODO test pdf embeds
Expand Down
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { recursiveWalkDir } from "./recursiveWalkDir.js";
export { parseFile } from "./parseFile.js";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseFile } from "../lib/parseFile";
import { parseFile } from "./parseFile";

const source = `---
title: Hello World
Expand Down
1 change: 0 additions & 1 deletion src/lib/parseFile.ts → src/utils/parseFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function parseFile(source: string, options?: ParsingOptions) {
};
}

// Exported for testing
export function processAST(source: string, options?: ParsingOptions) {
const userRemarkPlugins: Array<Plugin> = options?.remarkPlugins || [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { recursiveWalkDir } from "../lib/recursiveWalkDir";
import { recursiveWalkDir } from "./recursiveWalkDir";

describe("recursiveWalkDir", () => {
const contentFixturePath = "__mocks__/content/blog";
Expand Down
File renamed without changes.

0 comments on commit 70330d1

Please sign in to comment.