-
Notifications
You must be signed in to change notification settings - Fork 28
Fixes error that occurs when local storage is enabled. #62
Conversation
fathyb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add tests to prevent any regressions?
I don't think we usually bump the version in a PR, I think this will prevent the tag v4.2.1 from being created. Could you revert this commit?
e4e5db7 to
0fc1b58
Compare
|
To confirm, did you mean this error occurs when when local storage is disabled? Agree a unit test would be good to have here! |
…rossDomain is disabled.
test/index.test.js
Outdated
| it('identify should not ultimately call getCachedCrossDomainId if crossDomainAnalytics is not enabled', function() { | ||
| var wasCalled = false; | ||
| var oldCrossDomainCheck = segment.isCrossDomainAnalyticsEnabled; | ||
| segment.isCrossDomainAnalyticsEnabled = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think isCrossDomainAnalyticsEnabled needs to be mocked, it can be disabled with segment.options.crossDomainIdServers = []; (example here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
test/index.test.js
Outdated
| return false; | ||
| }; | ||
| var oldGetCrossDomainId = segment.getCachedCrossDomainId; | ||
| segment.getCachedCrossDomainId = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could/should we use sinon for this?
https://sinonjs.org/releases/v7.4.1/spy-call/
segment.options.crossDomainIdServers = [];
var getCachedCrossDomainIdSpy = sinon.spy(segment, "getCachedCrossDomainId");
segment.normalize({});
sinon.assert.notCalled(getCachedCrossDomainIdSpy);
segment.getCachedCrossDomainId.restore();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
Uh oh!
There was an error while loading. Please reload this page.