Skip to content

Commit

Permalink
Fixes 2 unit tests (#14561)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkeller authored and keithwrightbos committed Apr 12, 2018
1 parent 14a9c4b commit 839ec0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions extensions/amp-analytics/0.1/test/test-amp-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,26 @@ describes.realWin('amp-analytics', {

it('does not unnecessarily preload iframe transport script', function() {
const el = doc.createElement('amp-analytics');
el.setAttribute('type', 'foo');
doc.body.appendChild(el);
const analytics = new AmpAnalytics(el);
sandbox.stub(analytics, 'assertAmpAdResourceId').callsFake(() => 'fakeId');
const preloadSpy = sandbox.spy(analytics, 'preload');
sandbox.stub(analytics, 'predefinedConfig_').value(
{
'foo': {
'triggers': {
'sample_visibility_trigger': {
'on': 'visible',
'request': 'sample_visibility_request',
},
},
'requests': {
'sample_visibility_request': 'fake-request',
},
},
}
);
analytics.buildCallback();
analytics.preconnectCallback();
return analytics.layoutCallback().then(() => {
Expand Down
12 changes: 10 additions & 2 deletions extensions/amp-analytics/0.1/test/test-visibility-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,19 @@ describes.fakeWin('VisibilityManagerForDoc', {amp: true}, env => {

it('does not allow min==max, when they are neither 0 nor 100', () => {
let spec = {visiblePercentageThresholds: [[50, 50]]};
root.listenRoot(spec, null, null, null);
allowConsoleError(() => {
// Expect user().error(TAG,
// 'visiblePercentageThresholds entry invalid min/max value')
root.listenRoot(spec, null, null, null);
});
expect(root.models_).to.have.length(0);
root.dispose();
spec = {visiblePercentageThresholds: [[0, 10], [10, 10], [30, 30]]};
root.listenRoot(spec, null, null, null);
allowConsoleError(() => {
// On the [10, 10] only, again expect user().error(TAG,
// 'visiblePercentageThresholds entry invalid min/max value')
root.listenRoot(spec, null, null, null);
});
expect(root.models_).to.have.length(1);
root.dispose();
});
Expand Down

0 comments on commit 839ec0e

Please sign in to comment.