diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/generateApi.spec.ts | 11 | ||||
-rw-r--r-- | test/index.spec.ts | 2 | ||||
-rw-r--r-- | test/samples/2019/12/12/category.md | 13 |
3 files changed, 24 insertions, 2 deletions
diff --git a/test/generateApi.spec.ts b/test/generateApi.spec.ts index bf63b6e..f22c8e4 100644 --- a/test/generateApi.spec.ts +++ b/test/generateApi.spec.ts @@ -2,12 +2,21 @@ import * as fs from "fs"; import Kronikarz from "../dist"; const k = new Kronikarz(__dirname + "/samples"); +const dir = "./tmp"; test("generate single file", () => { - const dir = "./tmp"; k.generateApi(dir); fs.readFile("./tmp/api/posts/2019/12/12/test.json", "utf-8", (err, data) => { const parsedPost = JSON.parse(data); expect(parsedPost.title).toBe("Test"); }); }); + +test("categories", () => { + k.generateApi(dir) + fs.readFile(`${dir}/api/category/test-category.json`, "utf-8", (err, data) => { + const posts = JSON.parse(data) + expect(posts.length).toBe(1) + expect(posts[0].content).toBe(undefined) + }) +}) diff --git a/test/index.spec.ts b/test/index.spec.ts index 4fd65e1..4622724 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -2,5 +2,5 @@ import Kronikarz from "../dist"; test("basic", () => { const k = new Kronikarz(__dirname + "/samples"); - expect(k.getPosts().length).toBe(1); + expect(k.getPosts().length).toBe(2); }); diff --git a/test/samples/2019/12/12/category.md b/test/samples/2019/12/12/category.md new file mode 100644 index 0000000..e7f04e7 --- /dev/null +++ b/test/samples/2019/12/12/category.md @@ -0,0 +1,13 @@ +--- +title: Category +author: Tester +category: + - test-category +--- + +# Category + +01-01-2020 | Tester + +This file is for testing categories + |