notion-to-md icon indicating copy to clipboard operation
notion-to-md copied to clipboard

Missing tests

Open Souvikns opened this issue 2 years ago • 3 comments

In the context of testing I would like to talk about two things

  1. Hitting Notion API to fetch block contents now to successfully run this tests we will be depending on notion API and need an API key and also the database has to follow a pattern which will be hard to test locally every time anyone clones the repo.
  2. Secondly we are parsing the block JSON object and converting it into markdown flavored string, I think this is something we can test effectively and should mock the block data structure to do so.

Souvikns avatar Dec 19 '21 14:12 Souvikns

I think we can do unit tests with jest or other testing framework and just mock the structure of notion blocks. In this way we can make sure that the output is as expected.

scopsy avatar Jan 28 '22 11:01 scopsy

I'm not sure if that'll work as each method depends on the notion client SDK (excluding toMarkdownString). So internally recursive API calls are being made to fetch the child blocks. I guess we can create a dummy notion document and pass the auth token as an environment variable to the CI/CD. If someone wants to run locally then probably they have to provide theirs.

souvikinator avatar Jan 28 '22 17:01 souvikinator

I've created a base jest infra in #17 we can expand it and create mocks to the notion client API easily with jest.

scopsy avatar Jan 29 '22 08:01 scopsy