huytd / pomoday-v2

A keyboard only task management web app
https://pomoday.vercel.app
BSD 3-Clause "New" or "Revised" License
586 stars 68 forks source link

Add initial testing for commands listed in help text #8

Closed karlbright closed 4 years ago

karlbright commented 5 years ago

Adds testing around the commands helper, using the commands listed within the help text.

I wanted to look at expanding on functionality around some of these commands, but given the lack of tests I thought it best to start there and make it easy to refactor or expand on in a future pull requests.

I'm not sure on your thoughts for testing framework, but tape has always served me well and is easy enough to follow. Given the state of the codebase currently, it seemed a good fit.

TAP version 13
# t @work This is a new task
ok 1 should be correct command
ok 2 should have correct tag or tags
ok 3 should have correct text
ok 4 should have correct id or ids
# task @longer-task This is another task
ok 5 should be correct command
ok 6 should have correct tag or tags

....

ok 80 should have correct id or ids
# light
ok 81 should be correct command
ok 82 should have correct tag or tags
ok 83 should have correct text
ok 84 should have correct id or ids

1..84
# tests 84
# pass  84

# ok
huytd commented 5 years ago

Sorry for late response, I'll find sometimes this weekend to look at this PR. And thank you so much! This is definitely needed!

karlbright commented 5 years ago

@huytd No worries. Fixed merge conflicts so it should be all good to go.

huytd commented 5 years ago

@karlbright Thanks for bringing this up. Regarding to the test framework, honestly I never use or heard about tape before. But looking at it, I think I like the lightweight-ness of it. So I'll give it a try in this project then.

karlbright commented 4 years ago

@huytd This has been fixed up to use strings for IDs. Updating the tests to use strings caught an issue with the implementation of the move command, where ID's were being returned with their whitespace due to the matching group setup. I've fixed that up in 4fa0e5c to ensure the tests pass correctly as a result of this PR.

huytd commented 4 years ago

Awesome. Thank you so much. Merging now.