hubot-archive / hubot-auth

Assign roles to users and restrict command access in other scripts
149 stars 54 forks source link

unit tests for scripts calling Auth? #47

Open IAmPatrickB opened 7 years ago

IAmPatrickB commented 7 years ago

Has anyone written unit tests for scripts that include/call hubot-auth? I haven't found any solid examples of how to stub out the 'hasRole' or 'isAdmin' functions. I've played around with my own using sinonjs, but when I finally get it passing, the script actually doesn't work in chat, and a working script doesn't pass the unit tests. It also requires modification to auth.coffee in order to get it to pass the test.

I'm guessing I'm probably doing it wrong. Has anyone stubbed this out before?

sebastiandero commented 7 years ago

@GSAgentP I dont think unit tests are possible when implementing hubot listener function, i recommend you pull out everything you can using methods, which you can test.

sebastiandero commented 7 years ago

@GSAgentP nvm, just figured out it is indeed possible hubot-test-helper is the package you need to be looking at