Unit tests for event-based interactivity

25 views
Skip to first unread message

Steve Dee

unread,
Apr 3, 2010, 12:55:07 AM4/3/10
to closure-lib...@googlegroups.com
Let's say I'm writing some code that is supposed to perform some action -- say, transform the contents of a textarea -- on keyboard events. It's easy enough to set up the required event listeners in the test code to verify this, but what I'm having trouble with is simulating the events themselves. It doesn't appear as though just doing e.g. a dispatchEvent(goog.events.EventType.KEYUP) works here. Is there a robust or preferred way to do this sort of thing? Or am I looking at the problem the wrong way in the first place? Are there any examples of event-driven code with unit tests in Closure?

Nick Santos

unread,
Apr 3, 2010, 1:17:32 AM4/3/10
to closure-lib...@googlegroups.com
Have you seen goog.testing.events? Does that meet your needs, or did
you have something else in mind?

Nick

Steve Dee

unread,
Apr 3, 2010, 1:41:46 AM4/3/10
to closure-lib...@googlegroups.com
Oh! Terrific---thanks. I hadn't seen that, in fact.

Is there a comprehensive guide to the Closure testing tools? I think testing especially is a case where example-driven learning works well; I'd love to see a worked example of a project written in TDD style in Closure. Of course there's always reading the test code for the Closure source or the API docs, but I feel like that might miss some of processes and the mindset involved.



--
To unsubscribe, reply using "remove me" as the subject.

Reply all
Reply to author
Forward
0 new messages