1

I'm using Jasmine to write tests for a Titanium project. I have a custom util js to provide me information about the network availability.

In this util there is a helper method calling Titanium.Network.getNetworkType() to retrieve the current active network type. The action I do depends on the network type retrieved by this call. To ensure test coverage on this, I'm writing Jasmine tests. But unfortunately I'm having issues with spying on Titanium.Network.getNetworkType()

Code snippet:

console.log(Titanium.Network.getNetworkType()); // returns 1

spyOn(Titanium.Network, 'getNetworkType').andReturn(666);

console.log(Titanium.Network.getNetworkType()); // returns 1

Spying on a method of Titanium (e.g. getApiName()) does work. Any ideas on this?

Thanks.

Fokke Zandbergen
  • 3,866
  • 1
  • 11
  • 28
YakupKalin
  • 61
  • 4
  • Could you provide some more context? For example the Jasmine framework (like [this one](https://github.com/guilhermechapiewski/titanium-jasmine)) you are using? – Fokke Zandbergen May 02 '16 at 15:02

0 Answers0