Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsalem401 committed Jan 31, 2024
2 parents 986dca6 + 1b3c70d commit 39f1428
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# mddb

## 0.9.2

### Patch Changes

- [#108](https://github.com/datopian/markdowndb/pull/108) [`ea9cc83`](https://github.com/datopian/markdowndb/commit/ea9cc83e5315d256c80cf107ccd18caacaa6bc1a) Thanks [@mohamedsalem401](https://github.com/mohamedsalem401)! - - Add tests for document types
- Fix throwing an error when the document type is incorrect
- Fix linting error
- Fix a strange duplicated body tags issue
- Fix the library incorrectly stringifying strings
- Add tests for computed fields

## 0.9.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MarkdownDB

[![](https://badgen.net/npm/v/mddb)](https://www.npmjs.com/package/mddb)
[![](https://dcbadge.vercel.app/api/server/EeyfGrGu4U)](https://discord.gg/EeyfGrGu4U)
[![](https://dcbadge.vercel.app/api/server/xfFDMPU9dC)](https://discord.gg/xfFDMPU9dC)

MarkdownDB is a javascript library that turns markdown files into structured queryable databaase (SQL-based and simple JSON). It helps you build rich markdown-powered sites easily and reliably. Specifically it:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mddb",
"version": "0.9.1",
"version": "0.9.2",
"description": "Parse markdown files and store them in an SQL database.",
"bin": {
"mddb": "./dist/src/bin/index.js"
Expand Down
4 changes: 4 additions & 0 deletions src/lib/indexFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export function indexFolder(
)}" field: ${err.message}`;
console.error(errorMessage);
});

throw new Error(
"Validation Failed: Unable to validate files against the specified scheme. Ensure that the file formats and content adhere to the specified scheme."
);
}
throw new Error(
"Validation Failed: Unable to validate files against the specified scheme. Ensure that the file formats and content adhere to the specified scheme."
Expand Down
11 changes: 5 additions & 6 deletions src/tests/documentTypes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Document Types Schema Validate Testing", () => {
await mddb.db.destroy();
});

test("Should Throw an Error scheme validation failed", async () => {
test("Test that the 'indexFolder' function throws a validation error for a missing field in the blog schema.", async () => {
try {
await mddb.indexFolder({
folderPath: pathToContentFixture,
Expand All @@ -34,12 +34,12 @@ describe("Document Types Schema Validate Testing", () => {
},
},
});
fail("Expected an error, but none was thrown.");

fail("Expected a validation error due to a missing field in the blog schema, but none was thrown.");
} catch (error: any) {
expect(error).toBeInstanceOf(Error);
expect(error.message).toBe(
"Validation Failed: Unable to validate files against the specified scheme. Ensure that the file formats and content adhere to the specified scheme."
);
expect(error.message).toContain("Validation Failed: Unable to validate files against the specified scheme.");
;
}
});
test("Should check if the title field is created and save in db", async () => {
Expand All @@ -59,7 +59,6 @@ describe("Document Types Schema Validate Testing", () => {
},
});
const dbFiles = await mddb.getFiles({ filetypes: ["blog"] });
// console.log(JSON.stringify(dbFiles));
for (const file of dbFiles) {
expect(file.title).toBe("Hello");
}
Expand Down

0 comments on commit 39f1428

Please sign in to comment.