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 b26a7e7 commit 4aff486
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/utils/databaseUtils.ts → src/lib/databaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
MddbLink,
MddbFileTag,
File,
} from "../lib/schema.js";
} from "./schema.js";
import path from "path";
import { WikiLink } from "./parseFile.js";

Expand Down
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
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 "../utils/databaseUtils.js";
} from "./databaseUtils.js";

const defaultFilePathToUrl = (filePath: string) => {
let url = filePath
Expand Down
1 change: 1 addition & 0 deletions src/utils/parseFile.ts → src/lib/parseFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ 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
3 changes: 1 addition & 2 deletions src/lib/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ 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 } from "../utils/parseFile.js";
import { WikiLink, parseFile } from "./parseFile.js";

export interface FileInfo extends File {
tags: string[];
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extractTagsFromBody, processAST } from "./parseFile";
import { extractTagsFromBody, processAST } from "../lib/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 "./parseFile";
import { extractWikiLinks, processAST } from "../lib/parseFile";

// TODO test for links with headings and aliases ?
// TODO test pdf embeds
Expand Down
6 changes: 3 additions & 3 deletions src/lib/markdowndb.spec.ts → src/tests/markdowndb.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import knex from "knex";
import { MarkdownDB } from "./markdowndb";
import { File, MddbFile, Table } from "./schema";
import { recursiveWalkDir } from "../utils";
import { MarkdownDB } from "../lib/markdowndb";
import { recursiveWalkDir } from "../lib/recursiveWalkDir";
import { File, MddbFile, Table } from "../lib/schema";

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

const source = `---
title: Hello World
Expand Down
2 changes: 1 addition & 1 deletion src/lib/process.spec.ts → src/tests/process.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { processFile } from "./process";
import { processFile } from "../lib/process";
import Path from "path";

describe("Can parse a file and get file info", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { recursiveWalkDir } from "./recursiveWalkDir";
import { recursiveWalkDir } from "../lib/recursiveWalkDir";

describe("recursiveWalkDir", () => {
const contentFixturePath = "__mocks__/content/blog";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/validate.spec.ts → src/tests/validate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { areUniqueObjectsByKey } from "./validate";
import { areUniqueObjectsByKey } from "../lib/validate";

describe("areUniqueObjectsByKey", () => {
test("should return true if all objects have unique values for the given key", () => {
Expand Down
2 changes: 0 additions & 2 deletions src/utils/index.ts

This file was deleted.

0 comments on commit 4aff486

Please sign in to comment.