Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #9460
| From | storm.mark@gmail.com |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Is this the only way to unit-test an events abstraction? |
| Date | 2011-12-20 09:16 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <6567149.685.1324401412063.JavaMail.geo-discussion-forums@yqbo42> (permalink) |
Hi, I have two questions: 1.) How best to unit-test an event listener? 2.) Have I properly understood isHostMethod? I'm trying to unit-test an event listener abstraction but the only way I can think to test it is against the window 'load' event. I've a code example here: https://gist.github.com/1502326 Also, I'm using David Mark's (@cinsoft) isHostMethod to detect the relevant host object support but was wondering if I had properly understood the concepts or not? So for example, am I right in thinking that a host object/method should be available under the following conditions (although I understand that these 'conditions' are unreliable): - if typeof returns 'function' (for majority browsers) - if typeof returns 'unknown' (for IE < 9 where its implementation used ActiveX objects for native Functions) - if typeof returns 'object' and the value isn't 'null' (because ES3 specs have allowed null to return 'object' which is incorrect behaviour) If any of these conditions are true then that (again, unreliably) *should* mean that the specified host method is available to use. But even still the host object/method might be implemented differently to how the specification dictates it should be and so it would be more accurate to do full 'feature detection' where I create the object and see if an event is triggered (or some similar test)? Thanks for any advice regarding both these enquiries. Mark.
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Is this the only way to unit-test an events abstraction? storm.mark@gmail.com - 2011-12-20 09:16 -0800
Re: Is this the only way to unit-test an events abstraction? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-20 22:02 +0100
Re: Is this the only way to unit-test an events abstraction? storm.mark@gmail.com - 2011-12-21 01:27 -0800
Re: Is this the only way to unit-test an events abstraction? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-21 13:42 +0100
Re: Is this the only way to unit-test an events abstraction? John G Harris <john@nospam.demon.co.uk> - 2011-12-21 17:25 +0000
Re: Is this the only way to unit-test an events abstraction? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-21 20:30 +0100
Re: Is this the only way to unit-test an events abstraction? John G Harris <john@nospam.demon.co.uk> - 2011-12-22 15:22 +0000
csiph-web