summary refs log tree commit diff
path: root/test/generateApi.spec.ts
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-28 18:16:03 +0100
committerGitHub <noreply@github.com>2020-01-28 18:16:03 +0100
commit42c089293fed2db9c8a09d8e55f046169b5f0844 (patch)
tree18a053fe7f1e03fc5419a8c3d2a8bc8193cb27f0 /test/generateApi.spec.ts
parent7b8d75cd87e392d9ffb3defa538a041c4f7e0f0c (diff)
parentacfd4d0c722ceeca6aad51be64baf117e73f286c (diff)
downloadkronikarz-42c089293fed2db9c8a09d8e55f046169b5f0844.tar.gz
kronikarz-42c089293fed2db9c8a09d8e55f046169b5f0844.zip
Merge pull request #8 from pniedzwiedzinski/feature/generateApi v2.0
Feature/generate api
Diffstat (limited to 'test/generateApi.spec.ts')
-rw-r--r--test/generateApi.spec.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/generateApi.spec.ts b/test/generateApi.spec.ts
new file mode 100644
index 0000000..f22c8e4
--- /dev/null
+++ b/test/generateApi.spec.ts
@@ -0,0 +1,22 @@
+import * as fs from "fs";
+import Kronikarz from "../dist";
+
+const k = new Kronikarz(__dirname + "/samples");
+const dir = "./tmp";
+
+test("generate single file", () => {
+  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)
+    })
+})