storyblok / field-plugin

Create and deploy Storyblok Field Plugin
https://www.storyblok.com/docs/plugins/field-plugins/introduction
25 stars 3 forks source link

test(cli): add tests for deploy command #245

Closed BibiSebi closed 1 year ago

BibiSebi commented 1 year ago

What?

This PR includes tests for the deploy command of the CLI. Additionally it updates the Vitest version to be able to access unstubAllGlobals function which was not a part of the testing library before. Due to tests being made, some refactoring and splitting code into smaller functions was required.

Why?

JIRA:EXT-1895

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plugin-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 10, 2023 11:13am
BibiSebi commented 1 year ago

What do you think about the status of this PR? I think we could write one more test and merge this as-is before this consumes your time too much. What we could test more here is, to see if upsertFieldPlugin is being called correctly with the parameters.

After that test, in a separate PR, we can start testing those internal functions upsertFieldPlugin, getPackageName, ... but probably not now, not here.

@eunjae-lee you are right, I added two more test cases. Did not test everthing but lets say at leas 40% is now tested. I think we can merge if there are no issues, otherwise its also going to blow up fast as it also requires refactoring