api: Extract common Notion functionality to library.

This commit is contained in:
2021-10-30 22:36:41 -05:00
parent 3553ce4ea1
commit 06d2b3f384
8 changed files with 51 additions and 30 deletions

2
api/test/config.nims Normal file
View File

@@ -0,0 +1,2 @@
switch("path", "../src")
switch("verbosity", "0")

BIN
api/test/runner Executable file

Binary file not shown.

3
api/test/runner.nim Normal file
View File

@@ -0,0 +1,3 @@
import std/unittest
import ./tmodels

20
api/test/tmodels.nim Normal file
View File

@@ -0,0 +1,20 @@
import std/json, std/times, std/unittest
import hff_entry_forms_apipkg/models
suite "models":
test "asNotionPage(EventProposal)":
let ep = EventProposal(
name: "Test Event",
description: "A test event.",
purpose: "Event example for unit testing.",
department: "Testing",
location: "Hope Family Fellowship",
owner: "Jonathan Bernard",
date: parse("2021-10-30", "YYYY-MM-dd"),
budgetInDollars: 56)
let expectedJson = """{"properties":{"Event":{"title":[{"type":"text","text":{"content":"Test Event"}}]},"Date":{"date":{"start":"2021-10-30T00:00:00.000-05:00"}},"Department":{"multi_select":[{"name":"Testing"}]},"Location":{"rich_text":[{"type":"text","text":{"content":"Hope Family Fellowship"}}]},"Owner":{"rich_text":[{"type":"text","text":{"content":"Jonathan Bernard"}}]},"State":{"select":{"name":"Proposed"}}},"children":[{"object":"block","type":"heading_2","heading_2":{"text":[{"type":"text","text":{"content":"Purpose"}}]}},{"object":"block","type":"paragraph","paragraph":{"text":[{"type":"text","text":{"content":"Event example for unit testing."}}]}},{"object":"block","type":"heading_2","heading_2":{"text":[{"type":"text","text":{"content":"Description"}}]}},{"object":"block","type":"paragraph","paragraph":{"text":[{"type":"text","text":{"content":"A test event."}}]}}]}"""
check $(ep.asNotionPage) == expectedJson