Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create unit tests #24

Open
supasate opened this issue Sep 26, 2016 · 4 comments
Open

Create unit tests #24

supasate opened this issue Sep 26, 2016 · 4 comments

Comments

@supasate
Copy link
Contributor

No description provided.

@p16i
Copy link
Contributor

p16i commented Oct 2, 2016

Since most of logics for youpin-bot are inside youpin.js. So I think we can start from there.

@supasate
Copy link
Contributor Author

supasate commented Oct 2, 2016

Just read youpin.js. The function is so scarily long and hard to do unit test. Is is possible to break it into smaller functions? @tvirot

@tvirot
Copy link
Member

tvirot commented Oct 2, 2016

Lol, yup :) I think we can have one function to handle each state and turn
the long if-else clauses into a switch-case statement calling a proper
function based on the current state.

On Sunday, October 2, 2016, Supasate Choochaisri notifications@github.com
wrote:

Just read youpin.js. The function is so scarily long and hard to do unit
test. Is is possible to break it into smaller functions? @tvirot
https://github.com/tvirot


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#24 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEssY66arjaO58akOVSR4iraboNLUSByks5qv-B1gaJpZM4KGeiV
.

@p16i
Copy link
Contributor

p16i commented Oct 3, 2016

Here is my idea. We can separate the logics into STATE and put it in its own file under states directory. For each state, we might have something like this

function POST_A_PIN = {
    return {
        depends: [ WAITING_FOR_LOCATION, WAITING_FOR_IMAGE ]
        next: [ 'SAY_GOODBYE' ]
        onEnter: function(context){ ... }
    }
}

What do you think?
@supasate @tvirot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants