I’ve built a thin GWT Wrapper around an existing JavaScript API. The JavaScript API is independently tested, so all I want to do is test that the GWT Wrapper calls the correct JavaScript functions with the correct arguments. Any ideas on how to go about doing this?
Currently, the GWT API has a bunch of public methods which after a bit of processing call private native methods which make the JavaScript API calls.
Any guidance appreciated, thanks.
In the java world, what you asked for is usually done using delegation and interfaces.
I would make a (java) interface that corresponds one to one with the API that the js library, and then create a simple implementation of that interface.
Your wrapper code then wraps the interface instead. During test time, you replace the implementation of that interface with your own, where each method just asserts whether it is called or not.
E.g.