Skip to content

Commit

Permalink
Requested change
Browse files Browse the repository at this point in the history
  • Loading branch information
wassgha committed Aug 17, 2017
1 parent c3f5ee3 commit a84a879
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/event-helper-listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/
export function detectEvtListenerOptsSupport() {
// Only run the test once
if (typeof optsSupported != 'undefined') {
if (optsSupported !== undefined) {
return optsSupported;
}

Expand All @@ -95,6 +95,7 @@
},
};
self.addEventListener('test-opts', null, options);
self.removeEventListener('test-opts', null, options);
} catch (err) {
// EventListenerOptions are not supported
}
Expand All @@ -104,6 +105,6 @@
/**
* Resets the test for whether addEventListener supports options or not.
*/
export function resetEvtListenerOptsSupport() {
export function resetEvtListenerOptsSupportForTesting() {
optsSupported = undefined;
}
10 changes: 5 additions & 5 deletions test/functional/test-event-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from '../../src/event-helper';
import {
detectEvtListenerOptsSupport,
resetEvtListenerOptsSupport,
resetEvtListenerOptsSupportForTesting,
} from '../../src/event-helper-listen';
import {Observable} from '../../src/observable';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -260,14 +260,14 @@ describe('EventHelper', () => {
}
}
);
resetEvtListenerOptsSupport();
resetEvtListenerOptsSupportForTesting();
expect(detectEvtListenerOptsSupport()).to.be.true;
expect(addEventListenerStub.called).to.be.true;
resetEvtListenerOptsSupport();
resetEvtListenerOptsSupportForTesting();
});

it('should cache the result of the test and only do it once', () => {
resetEvtListenerOptsSupport();
resetEvtListenerOptsSupportForTesting();
expect(detectEvtListenerOptsSupport()).to.be.true;
expect(addEventListenerStub.called).to.be.true;
expect(detectEvtListenerOptsSupport()).to.be.true;
Expand All @@ -284,7 +284,7 @@ describe('EventHelper', () => {
}
}
);
resetEvtListenerOptsSupport();
resetEvtListenerOptsSupportForTesting();
expect(detectEvtListenerOptsSupport()).to.be.false;
expect(addEventListenerStub.called).to.be.true;
expect(detectEvtListenerOptsSupport()).to.be.false;
Expand Down

0 comments on commit a84a879

Please sign in to comment.