Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15643
| From | Dr J R Stockton <reply1235@merlyn.demon.co.uk.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How do you create a quick "mock"? |
| Date | 2012-08-31 23:22 +0100 |
| Organization | Home |
| Message-ID | <JDmdZbIhkTQQFwKQ@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <555ecc4f-6bca-4d8b-ae21-1b6e7978737d@googlegroups.com> |
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>.
Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread
Re: How do you create a quick "mock"? Dr J R Stockton <reply1235@merlyn.demon.co.uk.invalid> - 2012-08-31 23:22 +0100
csiph-web