diff --git a/CHANGELOG.md b/CHANGELOG.md index bdcf19f..4b64bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index e32dbd8..fda14ca 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/package.json b/package.json index 0050788..b2cba54 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/lib/indexFolder.ts b/src/lib/indexFolder.ts index e996d4e..4184ce3 100644 --- a/src/lib/indexFolder.ts +++ b/src/lib/indexFolder.ts @@ -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." diff --git a/src/tests/documentTypes.spec.ts b/src/tests/documentTypes.spec.ts index 35591da..cdca9eb 100644 --- a/src/tests/documentTypes.spec.ts +++ b/src/tests/documentTypes.spec.ts @@ -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, @@ -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 () => { @@ -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"); }