Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15643 > unrolled thread

Re: How do you create a quick "mock"?

Started byDr J R Stockton <reply1235@merlyn.demon.co.uk.invalid>
First post2012-08-31 23:22 +0100
Last post2012-08-31 23:22 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.javascript

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How do you create a quick "mock"? Dr J R Stockton <reply1235@merlyn.demon.co.uk.invalid> - 2012-08-31 23:22 +0100

#15643 — Re: How do you create a quick "mock"?

FromDr J R Stockton <reply1235@merlyn.demon.co.uk.invalid>
Date2012-08-31 23:22 +0100
SubjectRe: How do you create a quick "mock"?
Message-ID<JDmdZbIhkTQQFwKQ@invalid.uk.co.demon.merlyn.invalid>
In comp.lang.javascript message <555ecc4f-6bca-4d8b-ae21-1b6e7978737d@go
oglegroups.com>, Thu, 30 Aug 2012 13:46:44, Dave <drathnow@gmail.com>
posted:

>JavaScript newbie question:
>
>I have a function (method) that takes an object as an argument, which
>has some methods:
>
>someMethod: function(geo) {
>    ...
>    var lat = geo.getLatitute();
>    var long = geo.getLongitude();
>    ...
>}
>
>I want to do a quick test the function by passing in a mock object that
>provides mock implementations of the two methods.  How would I do this?
>I've tried this but it doesn't seem to work:
>
>someMethod(new function(){
>                function getLatitude() {
>                    return 11;
>                }
>
>                function getLongitude() {
>                    return 22;
>                }
>            });

Does spelling "getLatitude" the same way every time help?

-- 
 (c) John Stockton, nr London, UK.  For Mail, see Home Page.  Turnpike, WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web