Reputation: 1212
I'm writing an integration test using QUnit, and in my webapp if geolocation is not available, (I use if (navigator.geolocation)
to detect if is present or not, but I want to disable it in order to implement the test when geolocation is not available.
I tried navigator.geolocation = undefined
but unfortunately it didn't work.
Upvotes: 0
Views: 1928
Reputation: 32511
You can't really "disable" navigator.geolocation
since it's a read-only property.
Instead, you could create a wrapper that checks for certain functionality and then mock it up for your tests.
var supports = {
geolocation: !!navigator.geolocation // will be `true` if geolocation is defined
};
// In your tests...
supports.geolocation = false;
executeTest();
Upvotes: 2