зеркало из https://github.com/mozilla/bedrock.git
Родитель
66539aa3fb
Коммит
d83bd3934b
|
@ -12,7 +12,7 @@ jobs:
|
||||||
|
|
||||||
test_js:
|
test_js:
|
||||||
docker:
|
docker:
|
||||||
- image: "circleci/node:6.14.0-browsers"
|
- image: "circleci/node:10.15.0-browsers"
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
* */
|
* */
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
files: 'gulpfile.js',
|
files: ['gulpfile.js', 'tests/unit/karma.conf.js'],
|
||||||
env: {
|
env: {
|
||||||
'commonjs': true,
|
'commonjs': true,
|
||||||
'node': true,
|
'node': true,
|
||||||
|
|
|
@ -46,7 +46,8 @@ if (typeof window.Mozilla === 'undefined') {
|
||||||
* @return {String} url + additional parameters.
|
* @return {String} url + additional parameters.
|
||||||
*/
|
*/
|
||||||
StubAttributionMacOS.appendToDownloadURL = function (url, data) {
|
StubAttributionMacOS.appendToDownloadURL = function (url, data) {
|
||||||
var finalParams = data;
|
// clone the passed `data` object to avoid mutating it indirectly.
|
||||||
|
var finalParams = Object.assign({}, data);
|
||||||
var linkParams;
|
var linkParams;
|
||||||
|
|
||||||
// if the link has a querystring, merge it with the utm_ params in the current
|
// if the link has a querystring, merge it with the utm_ params in the current
|
||||||
|
|
|
@ -199,8 +199,9 @@ if (typeof window.Mozilla === 'undefined') {
|
||||||
};
|
};
|
||||||
|
|
||||||
TPTour.handleVisibilityChange = function() {
|
TPTour.handleVisibilityChange = function() {
|
||||||
|
var hidden = typeof TPTour.documentHidden === 'boolean' ? TPTour.documentHidden : document.hidden;
|
||||||
clearTimeout(_highlightTimeout);
|
clearTimeout(_highlightTimeout);
|
||||||
if (TPTour.documentHidden || document.hidden) {
|
if (hidden) {
|
||||||
TPTour.hidePanels();
|
TPTour.hidePanels();
|
||||||
} else {
|
} else {
|
||||||
_highlightTimeout = setTimeout(TPTour.showTourStep, 300);
|
_highlightTimeout = setTimeout(TPTour.showTourStep, 300);
|
||||||
|
|
14
package.json
14
package.json
|
@ -22,7 +22,7 @@
|
||||||
"gulp-sourcemaps": "^2.6.4",
|
"gulp-sourcemaps": "^2.6.4",
|
||||||
"gulp-stylelint": "^3.9.0",
|
"gulp-stylelint": "^3.9.0",
|
||||||
"gulp-uglify": "^3.0.0",
|
"gulp-uglify": "^3.0.0",
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "2.0.0",
|
||||||
"yargs": "13.2.1"
|
"yargs": "13.2.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -37,12 +37,12 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browser-sync": "2.26.3",
|
"browser-sync": "2.26.3",
|
||||||
"concurrently": "4.1.0",
|
"concurrently": "4.1.0",
|
||||||
"jasmine-core": "^2.4.1",
|
"jasmine-core": "3.4.0",
|
||||||
"karma": "^0.13.22",
|
"karma": "4.1.0",
|
||||||
"karma-coverage": "^0.5.5",
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
"karma-firefox-launcher": "^0.1.7",
|
"karma-firefox-launcher": "1.1.0",
|
||||||
"karma-jasmine": "^0.3.8",
|
"karma-jasmine": "2.0.1",
|
||||||
"sinon": "^1.17.3"
|
"sinon": "7.3.2"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"browser-sync": "/.bin/browser-sync"
|
"browser-sync": "/.bin/browser-sync"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
config.set({
|
config.set({
|
||||||
// Karma configuration
|
// Karma configuration
|
||||||
|
@ -9,58 +11,55 @@ module.exports = function(config) {
|
||||||
|
|
||||||
// list of files / patterns to load in the browser
|
// list of files / patterns to load in the browser
|
||||||
files: [
|
files: [
|
||||||
|
// begin common dependencies.
|
||||||
'media/js/libs/jquery-3.4.1.min.js',
|
'media/js/libs/jquery-3.4.1.min.js',
|
||||||
'media/js/base/site.js',
|
'media/js/base/site.js',
|
||||||
'media/js/base/mozilla-utils.js',
|
'media/js/base/mozilla-utils.js',
|
||||||
'media/js/base/dnt-helper.js',
|
|
||||||
'media/js/base/core-datalayer-page-id.js',
|
|
||||||
'media/js/base/mozilla-accordion-gatrack.js',
|
|
||||||
'media/js/base/mozilla-accordion.js',
|
|
||||||
'media/js/base/mozilla-client.js',
|
'media/js/base/mozilla-client.js',
|
||||||
|
'media/js/base/search-params.js',
|
||||||
|
// end common dependencies.
|
||||||
|
'media/js/base/core-datalayer-page-id.js',
|
||||||
|
'media/js/base/core-datalayer.js',
|
||||||
|
'media/js/base/dnt-helper.js',
|
||||||
|
'media/js/base/fxa-utm-referral.js',
|
||||||
|
'media/js/base/mozilla-accordion.js',
|
||||||
'media/js/base/mozilla-fxa.js',
|
'media/js/base/mozilla-fxa.js',
|
||||||
'media/js/base/mozilla-lazy-load.js',
|
'media/js/base/mozilla-lazy-load.js',
|
||||||
'media/js/base/mozilla-notification-banner.js',
|
'media/js/base/mozilla-notification-banner.js',
|
||||||
'media/js/base/mozilla-modal.js',
|
|
||||||
'media/js/base/mozilla-pager.js',
|
'media/js/base/mozilla-pager.js',
|
||||||
'media/js/base/mozilla-pixel.js',
|
'media/js/base/mozilla-pixel.js',
|
||||||
'media/js/base/mozilla-share-cta.js',
|
|
||||||
'media/js/base/mozilla-traffic-cop-funnelcake-geo.js',
|
'media/js/base/mozilla-traffic-cop-funnelcake-geo.js',
|
||||||
'media/js/base/mozilla-video-poster.js',
|
'media/js/base/send-to-device.js',
|
||||||
'media/js/base/mozilla-smoothscroll.js',
|
|
||||||
'media/js/base/search-params.js',
|
|
||||||
'media/js/base/stub-attribution.js',
|
|
||||||
'media/js/base/stub-attribution-custom.js',
|
'media/js/base/stub-attribution-custom.js',
|
||||||
'media/js/base/stub-attribution-macos.js',
|
'media/js/base/stub-attribution-macos.js',
|
||||||
|
'media/js/base/stub-attribution.js',
|
||||||
'media/js/firefox/all/all-downloads-unified.js',
|
'media/js/firefox/all/all-downloads-unified.js',
|
||||||
'media/js/firefox/new/yandex/scene1.js',
|
'media/js/firefox/new/yandex/scene1.js',
|
||||||
'media/js/firefox/tracking-protection-tour.js',
|
'media/js/firefox/tracking-protection-tour.js',
|
||||||
'media/js/ie8/mozilla-utils-ie8.js',
|
'media/js/ie8/mozilla-utils-ie8.js',
|
||||||
'media/js/base/send-to-device.js',
|
'tests/unit/spec/base/core-datalayer-page-id.js',
|
||||||
'media/js/base/core-datalayer.js',
|
'tests/unit/spec/base/core-datalayer.js',
|
||||||
'media/js/base/fxa-utm-referral.js',
|
|
||||||
'tests/unit/spec/base/site.js',
|
|
||||||
'tests/unit/spec/base/mozilla-utils.js',
|
|
||||||
'tests/unit/spec/base/dnt-helper.js',
|
'tests/unit/spec/base/dnt-helper.js',
|
||||||
'tests/unit/spec/base/fxa-utm-referral.js',
|
'tests/unit/spec/base/fxa-utm-referral.js',
|
||||||
'tests/unit/spec/base/core-datalayer-page-id.js',
|
'tests/unit/spec/base/mozilla-accordion.js',
|
||||||
'tests/unit/spec/base/mozilla-client.js',
|
'tests/unit/spec/base/mozilla-client.js',
|
||||||
'tests/unit/spec/base/mozilla-fxa.js',
|
'tests/unit/spec/base/mozilla-fxa.js',
|
||||||
'tests/unit/spec/base/mozilla-lazy-load.js',
|
'tests/unit/spec/base/mozilla-lazy-load.js',
|
||||||
'tests/unit/spec/base/mozilla-notification-banner.js',
|
'tests/unit/spec/base/mozilla-notification-banner.js',
|
||||||
'tests/unit/spec/base/mozilla-accordion.js',
|
|
||||||
'tests/unit/spec/base/mozilla-pager.js',
|
'tests/unit/spec/base/mozilla-pager.js',
|
||||||
'tests/unit/spec/base/mozilla-pixel.js',
|
'tests/unit/spec/base/mozilla-pixel.js',
|
||||||
'tests/unit/spec/base/search-params.js',
|
|
||||||
'tests/unit/spec/base/mozilla-traffic-cop-funnelcake-geo.js',
|
'tests/unit/spec/base/mozilla-traffic-cop-funnelcake-geo.js',
|
||||||
|
'tests/unit/spec/base/mozilla-utils.js',
|
||||||
|
'tests/unit/spec/base/search-params.js',
|
||||||
|
'tests/unit/spec/base/send-to-device.js',
|
||||||
|
'tests/unit/spec/base/site.js',
|
||||||
|
'tests/unit/spec/base/stub-attribution-custom.js',
|
||||||
|
'tests/unit/spec/base/stub-attribution-macos.js',
|
||||||
|
'tests/unit/spec/base/stub-attribution.js',
|
||||||
'tests/unit/spec/firefox/all/all-downloads-unified.js',
|
'tests/unit/spec/firefox/all/all-downloads-unified.js',
|
||||||
'tests/unit/spec/firefox/new/yandex/scene1.js',
|
'tests/unit/spec/firefox/new/yandex/scene1.js',
|
||||||
'tests/unit/spec/firefox/tracking-protection-tour.js',
|
'tests/unit/spec/firefox/tracking-protection-tour.js',
|
||||||
'tests/unit/spec/ie8/mozilla-utils-ie8.js',
|
'tests/unit/spec/ie8/mozilla-utils-ie8.js',
|
||||||
'tests/unit/spec/base/send-to-device.js',
|
|
||||||
'tests/unit/spec/base/core-datalayer.js',
|
|
||||||
'tests/unit/spec/base/stub-attribution.js',
|
|
||||||
'tests/unit/spec/base/stub-attribution-custom.js',
|
|
||||||
'tests/unit/spec/base/stub-attribution-macos.js',
|
|
||||||
{
|
{
|
||||||
pattern: 'node_modules/sinon/pkg/sinon.js',
|
pattern: 'node_modules/sinon/pkg/sinon.js',
|
||||||
watched: false,
|
watched: false,
|
||||||
|
@ -82,21 +81,7 @@ module.exports = function(config) {
|
||||||
|
|
||||||
// test results reporter to use
|
// test results reporter to use
|
||||||
// possible values: 'dots', 'progress', 'junit', 'coverage'
|
// possible values: 'dots', 'progress', 'junit', 'coverage'
|
||||||
reporters: ['dots', 'coverage'],
|
reporters: ['progress'],
|
||||||
|
|
||||||
preprocessors: {
|
|
||||||
'media/js/**/!(libs|test)/*.js': ['coverage']
|
|
||||||
},
|
|
||||||
|
|
||||||
coverageReporter: {
|
|
||||||
type: 'lcov',
|
|
||||||
dir: 'tests/unit/coverage/',
|
|
||||||
instrumenterOptions: {
|
|
||||||
istanbul: {
|
|
||||||
noCompact: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// web server port
|
// web server port
|
||||||
port: 9876,
|
port: 9876,
|
||||||
|
@ -112,7 +97,7 @@ module.exports = function(config) {
|
||||||
//logLevel: console.LOG_INFO,
|
//logLevel: console.LOG_INFO,
|
||||||
|
|
||||||
// enable / disable watching file and executing tests whenever any file changes
|
// enable / disable watching file and executing tests whenever any file changes
|
||||||
autoWatch: true,
|
autoWatch: false,
|
||||||
|
|
||||||
// Start these browsers, currently available:
|
// Start these browsers, currently available:
|
||||||
// - Chrome
|
// - Chrome
|
||||||
|
@ -122,7 +107,7 @@ module.exports = function(config) {
|
||||||
// - Safari (only Mac)
|
// - Safari (only Mac)
|
||||||
// - PhantomJS
|
// - PhantomJS
|
||||||
// - IE (only Windows)
|
// - IE (only Windows)
|
||||||
browsers: ['Firefox'],
|
browsers: ['Firefox', 'Chrome'],
|
||||||
|
|
||||||
// If browser does not capture in given timeout [ms], kill it
|
// If browser does not capture in given timeout [ms], kill it
|
||||||
captureTimeout: 60000,
|
captureTimeout: 60000,
|
||||||
|
|
|
@ -528,19 +528,16 @@ describe('mozilla-client.js', function() {
|
||||||
|
|
||||||
it('should fire the callback function with a FxA details object', function() {
|
it('should fire the callback function with a FxA details object', function() {
|
||||||
var callback1 = jasmine.createSpy('callback1');
|
var callback1 = jasmine.createSpy('callback1');
|
||||||
var result = {
|
|
||||||
'firefox': true,
|
|
||||||
'legacy': false,
|
|
||||||
'mobile': false,
|
|
||||||
'setup': false,
|
|
||||||
'desktopDevices': false,
|
|
||||||
'mobileDevices': false
|
|
||||||
};
|
|
||||||
|
|
||||||
window.Mozilla.Client.getFxaDetails(callback1);
|
window.Mozilla.Client.getFxaDetails(callback1);
|
||||||
jasmine.clock().tick(500);
|
jasmine.clock().tick(500);
|
||||||
expect(callback1).toHaveBeenCalledWith(result);
|
expect(callback1).toHaveBeenCalled();
|
||||||
expect(window.Mozilla.Client.FxaDetails).toEqual(result);
|
expect(typeof window.Mozilla.Client.FxaDetails.firefox).toEqual('boolean');
|
||||||
|
expect(typeof window.Mozilla.Client.FxaDetails.legacy).toEqual('boolean');
|
||||||
|
expect(typeof window.Mozilla.Client.FxaDetails.mobile).toEqual('boolean');
|
||||||
|
expect(typeof window.Mozilla.Client.FxaDetails.setup).toEqual('boolean');
|
||||||
|
expect(typeof window.Mozilla.Client.FxaDetails.desktopDevices).toEqual('boolean');
|
||||||
|
expect(typeof window.Mozilla.Client.FxaDetails.mobileDevices).toEqual('boolean');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,10 +16,22 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
window.Mozilla.Cookies.setItem = sinon.stub();
|
window.Mozilla.Cookies.setItem = sinon.stub();
|
||||||
window.Mozilla.Cookies.getItem = sinon.stub();
|
window.Mozilla.Cookies.getItem = sinon.stub();
|
||||||
window.Mozilla.Cookies.hasItem = sinon.stub();
|
window.Mozilla.Cookies.hasItem = sinon.stub();
|
||||||
|
|
||||||
|
// stub out google tag manager
|
||||||
|
window.dataLayer = sinon.stub();
|
||||||
|
window.dataLayer.push = sinon.stub();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('init', function() {
|
describe('init', function() {
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
var notification = document.querySelector('.notification-banner');
|
||||||
|
|
||||||
|
if (notification) {
|
||||||
|
document.body.removeChild(notification);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
'id': 'fx-out-of-date-banner-copy1-direct-1',
|
'id': 'fx-out-of-date-banner-copy1-direct-1',
|
||||||
'name': 'fx-out-of-date',
|
'name': 'fx-out-of-date',
|
||||||
|
@ -124,6 +136,14 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
|
|
||||||
describe('show', function() {
|
describe('show', function() {
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
var notification = document.querySelector('.notification-banner');
|
||||||
|
|
||||||
|
if (notification) {
|
||||||
|
document.body.removeChild(notification);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('should display the notification and set a cookie', function() {
|
it('should display the notification and set a cookie', function() {
|
||||||
var options = {
|
var options = {
|
||||||
'id': 'fx-out-of-date-banner-copy1-direct-1',
|
'id': 'fx-out-of-date-banner-copy1-direct-1',
|
||||||
|
@ -151,7 +171,6 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
expect(Mozilla.NotificationBanner.bind).toHaveBeenCalled();
|
expect(Mozilla.NotificationBanner.bind).toHaveBeenCalled();
|
||||||
expect(Mozilla.NotificationBanner.setCookie).toHaveBeenCalledWith(options.id);
|
expect(Mozilla.NotificationBanner.setCookie).toHaveBeenCalledWith(options.id);
|
||||||
expect(Mozilla.NotificationBanner.trackGAShow).toHaveBeenCalledWith(options);
|
expect(Mozilla.NotificationBanner.trackGAShow).toHaveBeenCalledWith(options);
|
||||||
document.body.removeChild(notification);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -239,7 +258,31 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
|
|
||||||
describe('confirm', function() {
|
describe('confirm', function() {
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
var notification = document.querySelector('.notification-banner');
|
||||||
|
|
||||||
|
if (notification) {
|
||||||
|
document.body.removeChild(notification);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('should set a cookie before redirecting for regular click', function() {
|
it('should set a cookie before redirecting for regular click', function() {
|
||||||
|
var options = {
|
||||||
|
'id': 'fx-out-of-date-banner-copy1-direct-1',
|
||||||
|
'name': 'fx-out-of-date',
|
||||||
|
'experimentName': 'fx-out-of-date-banner-copy1',
|
||||||
|
'experimentVariant': 'direct-1',
|
||||||
|
'heading': 'Your browser security is at risk.',
|
||||||
|
'message': 'Update Firefox now to protect yourself from the latest malware.',
|
||||||
|
'confirm': 'Update now',
|
||||||
|
'gaConfirmAction': 'Update Firefox',
|
||||||
|
'gaConfirmLabel': 'Firefox for Desktop',
|
||||||
|
'url': '/firefox/download/thanks/',
|
||||||
|
'close': 'Close',
|
||||||
|
'gaCloseLabel': 'Close',
|
||||||
|
'confirmClick': null
|
||||||
|
};
|
||||||
|
|
||||||
var event = {
|
var event = {
|
||||||
'metaKey': false,
|
'metaKey': false,
|
||||||
'ctrlKey': false,
|
'ctrlKey': false,
|
||||||
|
@ -251,6 +294,7 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
spyOn(Mozilla.NotificationBanner, 'doRedirect');
|
spyOn(Mozilla.NotificationBanner, 'doRedirect');
|
||||||
spyOn(Mozilla.NotificationBanner, 'trackGAConfirm');
|
spyOn(Mozilla.NotificationBanner, 'trackGAConfirm');
|
||||||
spyOn(event, 'preventDefault');
|
spyOn(event, 'preventDefault');
|
||||||
|
Mozilla.NotificationBanner.init(options);
|
||||||
Mozilla.NotificationBanner.confirm(event);
|
Mozilla.NotificationBanner.confirm(event);
|
||||||
expect(event.preventDefault).toHaveBeenCalled();
|
expect(event.preventDefault).toHaveBeenCalled();
|
||||||
expect(Mozilla.NotificationBanner.setCookie).toHaveBeenCalledWith(Mozilla.NotificationBanner.COOKIE_INTERACTION_VALUE);
|
expect(Mozilla.NotificationBanner.setCookie).toHaveBeenCalledWith(Mozilla.NotificationBanner.COOKIE_INTERACTION_VALUE);
|
||||||
|
@ -259,6 +303,22 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should only set cookie for control click', function() {
|
it('should only set cookie for control click', function() {
|
||||||
|
var options = {
|
||||||
|
'id': 'fx-out-of-date-banner-copy1-direct-1',
|
||||||
|
'name': 'fx-out-of-date',
|
||||||
|
'experimentName': 'fx-out-of-date-banner-copy1',
|
||||||
|
'experimentVariant': 'direct-1',
|
||||||
|
'heading': 'Your browser security is at risk.',
|
||||||
|
'message': 'Update Firefox now to protect yourself from the latest malware.',
|
||||||
|
'confirm': 'Update now',
|
||||||
|
'gaConfirmAction': 'Update Firefox',
|
||||||
|
'gaConfirmLabel': 'Firefox for Desktop',
|
||||||
|
'url': '/firefox/download/thanks/',
|
||||||
|
'close': 'Close',
|
||||||
|
'gaCloseLabel': 'Close',
|
||||||
|
'confirmClick': null
|
||||||
|
};
|
||||||
|
|
||||||
var event = {
|
var event = {
|
||||||
'metaKey': false,
|
'metaKey': false,
|
||||||
'ctrlKey': true,
|
'ctrlKey': true,
|
||||||
|
@ -270,6 +330,7 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
spyOn(Mozilla.NotificationBanner, 'doRedirect');
|
spyOn(Mozilla.NotificationBanner, 'doRedirect');
|
||||||
spyOn(Mozilla.NotificationBanner, 'trackGAConfirm');
|
spyOn(Mozilla.NotificationBanner, 'trackGAConfirm');
|
||||||
spyOn(event, 'preventDefault');
|
spyOn(event, 'preventDefault');
|
||||||
|
Mozilla.NotificationBanner.init(options);
|
||||||
Mozilla.NotificationBanner.confirm(event);
|
Mozilla.NotificationBanner.confirm(event);
|
||||||
expect(event.preventDefault).not.toHaveBeenCalled();
|
expect(event.preventDefault).not.toHaveBeenCalled();
|
||||||
expect(Mozilla.NotificationBanner.setCookie).toHaveBeenCalledWith(Mozilla.NotificationBanner.COOKIE_INTERACTION_VALUE);
|
expect(Mozilla.NotificationBanner.setCookie).toHaveBeenCalledWith(Mozilla.NotificationBanner.COOKIE_INTERACTION_VALUE);
|
||||||
|
@ -291,7 +352,7 @@ describe('mozilla-notification-banner.js', function() {
|
||||||
'url': '/firefox/download/thanks/',
|
'url': '/firefox/download/thanks/',
|
||||||
'close': 'Close',
|
'close': 'Close',
|
||||||
'gaCloseLabel': 'Close',
|
'gaCloseLabel': 'Close',
|
||||||
confirmClick: function() {} // eslint-disable-line no-empty-function
|
'confirmClick': function() {} // eslint-disable-line no-empty-function
|
||||||
};
|
};
|
||||||
|
|
||||||
var event = {
|
var event = {
|
||||||
|
|
|
@ -236,6 +236,7 @@ describe('mozilla-pager.js', function () {
|
||||||
describe('Mozilla.Pager history', function () {
|
describe('Mozilla.Pager history', function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
Mozilla.Pager.monitoringHash = false;
|
||||||
$('<div id="pager" class="pager pager-with-tabs"><ol class="pager-tabs"><li><a href="#page1">Page 1</a></li><li><a href="#page2">Page 2</a></li></ol><div class="pager-content"><div class="pager-page"><p>Page 1</p></div><div class="pager-page"><p>Page 2</p></div></div></div>').appendTo('body');
|
$('<div id="pager" class="pager pager-with-tabs"><ol class="pager-tabs"><li><a href="#page1">Page 1</a></li><li><a href="#page2">Page 2</a></li></ol><div class="pager-content"><div class="pager-page"><p>Page 1</p></div><div class="pager-page"><p>Page 2</p></div></div></div>').appendTo('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -246,7 +247,7 @@ describe('mozilla-pager.js', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should monitor hash changes', function () {
|
it('should monitor hash changes', function () {
|
||||||
spyOn(Mozilla.Pager, 'initHashMonitor');
|
spyOn(Mozilla.Pager, 'initHashMonitor').and.callThrough();
|
||||||
Mozilla.Pager.createPagers();
|
Mozilla.Pager.createPagers();
|
||||||
expect(Mozilla.Pager.initHashMonitor).toHaveBeenCalled();
|
expect(Mozilla.Pager.initHashMonitor).toHaveBeenCalled();
|
||||||
expect(Mozilla.Pager.monitoringHash).toBeTruthy();
|
expect(Mozilla.Pager.monitoringHash).toBeTruthy();
|
||||||
|
|
|
@ -10,6 +10,15 @@
|
||||||
describe('mozilla-traffic-cop-funnelcake-geo.js', function() {
|
describe('mozilla-traffic-cop-funnelcake-geo.js', function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
// stub out Mozilla.Cookie lib
|
||||||
|
window.Mozilla.Cookies = sinon.stub();
|
||||||
|
window.Mozilla.Cookies.enabled = sinon.stub().returns(true);
|
||||||
|
window.Mozilla.Cookies.setItem = sinon.stub();
|
||||||
|
window.Mozilla.Cookies.getItem = sinon.stub();
|
||||||
|
window.Mozilla.Cookies.hasItem = sinon.stub();
|
||||||
|
});
|
||||||
|
|
||||||
describe('checkInCohort', function() {
|
describe('checkInCohort', function() {
|
||||||
it('should return true if user has the provided cookie', function() {
|
it('should return true if user has the provided cookie', function() {
|
||||||
spyOn(Mozilla.Cookies, 'hasItem').and.returnValue(true);
|
spyOn(Mozilla.Cookies, 'hasItem').and.returnValue(true);
|
||||||
|
|
|
@ -11,15 +11,15 @@ describe('search-params.js', function() {
|
||||||
|
|
||||||
describe('_SearchParams', function () {
|
describe('_SearchParams', function () {
|
||||||
|
|
||||||
var params = new _SearchParams('scene=2&source=getfirefox');
|
|
||||||
|
|
||||||
it('should return a proper value', function () {
|
it('should return a proper value', function () {
|
||||||
|
var params = new _SearchParams('scene=2&source=getfirefox');
|
||||||
expect(params.get('scene')).toEqual(2);
|
expect(params.get('scene')).toEqual(2);
|
||||||
expect(params.get('source')).toEqual('getfirefox');
|
expect(params.get('source')).toEqual('getfirefox');
|
||||||
expect(params.get('utm_campaign')).toBeUndefined();
|
expect(params.get('utm_campaign')).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set a proper value', function () {
|
it('should set a proper value', function () {
|
||||||
|
var params = new _SearchParams('scene=2&source=getfirefox');
|
||||||
params.set('scene', '3');
|
params.set('scene', '3');
|
||||||
params.set('utm_medium', 'referral');
|
params.set('utm_medium', 'referral');
|
||||||
expect(params.get('scene')).toEqual(3);
|
expect(params.get('scene')).toEqual(3);
|
||||||
|
@ -27,19 +27,22 @@ describe('search-params.js', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should detect if the key exists', function () {
|
it('should detect if the key exists', function () {
|
||||||
|
var params = new _SearchParams('scene=2&source=getfirefox');
|
||||||
expect(params.has('scene')).toBeTruthy();
|
expect(params.has('scene')).toBeTruthy();
|
||||||
expect(params.has('utm_medium')).toBeTruthy();
|
expect(params.has('source')).toBeTruthy();
|
||||||
expect(params.has('utm_source')).toBeFalsy();
|
expect(params.has('utm_source')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove a value', function () {
|
it('should remove a value', function () {
|
||||||
|
var params = new _SearchParams('scene=2&source=getfirefox');
|
||||||
params.remove('utm_medium');
|
params.remove('utm_medium');
|
||||||
expect(params.has('utm_medium')).toBeFalsy();
|
expect(params.has('utm_medium')).toBeFalsy();
|
||||||
expect(params.get('utm_medium')).toBeUndefined();
|
expect(params.get('utm_medium')).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a param string', function () {
|
it('should return a param string', function () {
|
||||||
expect(params.toString()).toEqual('scene=3&source=getfirefox');
|
var params = new _SearchParams('scene=2&source=getfirefox');
|
||||||
|
expect(params.toString()).toEqual('scene=2&source=getfirefox');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an object of utm_ values', function () {
|
it('should return an object of utm_ values', function () {
|
||||||
|
|
|
@ -37,9 +37,14 @@ describe('send-to-device.js', function() {
|
||||||
|
|
||||||
$(formMarkup).appendTo('body');
|
$(formMarkup).appendTo('body');
|
||||||
|
|
||||||
|
// stub out spinner.js
|
||||||
window.Spinner = sinon.stub();
|
window.Spinner = sinon.stub();
|
||||||
window.Spinner.prototype.spin = sinon.stub();
|
window.Spinner.prototype.spin = sinon.stub();
|
||||||
|
|
||||||
|
// stub out google tag manager
|
||||||
|
window.dataLayer = sinon.stub();
|
||||||
|
window.dataLayer.push = sinon.stub();
|
||||||
|
|
||||||
form = new Mozilla.SendToDevice();
|
form = new Mozilla.SendToDevice();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('all-downloads-unified.js', function() {
|
||||||
].join();
|
].join();
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
document.documentElement.insertAdjacentHTML('beforeend', select);
|
document.body.insertAdjacentHTML('beforeend', select);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -53,7 +53,7 @@ describe('all-downloads-unified.js', function() {
|
||||||
].join();
|
].join();
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
document.documentElement.insertAdjacentHTML('beforeend', select);
|
document.body.insertAdjacentHTML('beforeend', select);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -105,7 +105,7 @@ describe('all-downloads-unified.js', function() {
|
||||||
].join();
|
].join();
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
document.documentElement.insertAdjacentHTML('beforeend', downloadList);
|
document.body.insertAdjacentHTML('beforeend', downloadList);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -127,7 +127,7 @@ describe('all-downloads-unified.js', function() {
|
||||||
var downloadLink = '<a href="#" id="download-button-primary">Download Now</a>';
|
var downloadLink = '<a href="#" id="download-button-primary">Download Now</a>';
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
document.documentElement.insertAdjacentHTML('beforeend', downloadLink);
|
document.body.insertAdjacentHTML('beforeend', downloadLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
@ -249,10 +249,10 @@ describe('all-downloads-unified.js', function() {
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
'</li>' +
|
'</li>' +
|
||||||
'</ol>'
|
'</ol>'
|
||||||
];
|
].join();
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
document.documentElement.insertAdjacentHTML('beforeend', options);
|
document.body.insertAdjacentHTML('beforeend', options);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
|
|
@ -10,6 +10,19 @@
|
||||||
describe('yandex-scene1.js', function() {
|
describe('yandex-scene1.js', function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
// stub out Mozilla.Cookie lib
|
||||||
|
window.Mozilla.Cookies = sinon.stub();
|
||||||
|
window.Mozilla.Cookies.enabled = sinon.stub().returns(true);
|
||||||
|
window.Mozilla.Cookies.setItem = sinon.stub();
|
||||||
|
window.Mozilla.Cookies.getItem = sinon.stub();
|
||||||
|
window.Mozilla.Cookies.hasItem = sinon.stub();
|
||||||
|
|
||||||
|
// stub out google tag manager
|
||||||
|
window.dataLayer = sinon.stub();
|
||||||
|
window.dataLayer.push = sinon.stub();
|
||||||
|
});
|
||||||
|
|
||||||
describe('getLocation', function() {
|
describe('getLocation', function() {
|
||||||
|
|
||||||
var xhr;
|
var xhr;
|
||||||
|
@ -79,16 +92,14 @@ describe('yandex-scene1.js', function() {
|
||||||
spyOn(Mozilla.Yandex, 'setCookie');
|
spyOn(Mozilla.Yandex, 'setCookie');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update page content on first call and set a cookie', function() {
|
it('should update page content on first call only and set a cookie', function() {
|
||||||
Mozilla.Yandex.onRequestComplete(country);
|
Mozilla.Yandex.onRequestComplete(country);
|
||||||
expect(Mozilla.Yandex.updatePageContent).toHaveBeenCalled();
|
expect(Mozilla.Yandex.updatePageContent).toHaveBeenCalled();
|
||||||
expect(Mozilla.Yandex.setCookie).toHaveBeenCalledWith(country);
|
expect(Mozilla.Yandex.setCookie).toHaveBeenCalledWith(country);
|
||||||
});
|
|
||||||
|
|
||||||
it('should not update page content on second call', function() {
|
|
||||||
Mozilla.Yandex.onRequestComplete(country);
|
Mozilla.Yandex.onRequestComplete(country);
|
||||||
expect(Mozilla.Yandex.updatePageContent).not.toHaveBeenCalled();
|
expect(Mozilla.Yandex.updatePageContent).toHaveBeenCalledTimes(1);
|
||||||
expect(Mozilla.Yandex.setCookie).not.toHaveBeenCalled();
|
expect(Mozilla.Yandex.setCookie).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ describe('tracking-protection-tour.js', function() {
|
||||||
|
|
||||||
describe('shoud open "controlCenter" and highlight "trackingUnblock" if target is available', function() {
|
describe('shoud open "controlCenter" and highlight "trackingUnblock" if target is available', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
spyOn(Mozilla.UITour, 'getConfiguration').and.callFake(function(configName, callback) {
|
spyOn(Mozilla.UITour, 'getConfiguration').and.callFake(function(configName, callback) {
|
||||||
callback({
|
callback({
|
||||||
targets: ['controlCenter-trackingUnblock']
|
targets: ['controlCenter-trackingUnblock']
|
||||||
|
@ -361,6 +361,10 @@ describe('tracking-protection-tour.js', function() {
|
||||||
|
|
||||||
describe('handleVisibilityChange', function() {
|
describe('handleVisibilityChange', function() {
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
Mozilla.TPTour.documentHidden = null;
|
||||||
|
});
|
||||||
|
|
||||||
it('should hide UITour highlights when document is hidden', function() {
|
it('should hide UITour highlights when document is hidden', function() {
|
||||||
Mozilla.TPTour.documentHidden = true;
|
Mozilla.TPTour.documentHidden = true;
|
||||||
spyOn(Mozilla.TPTour, 'hidePanels');
|
spyOn(Mozilla.TPTour, 'hidePanels');
|
||||||
|
|
880
yarn.lock
880
yarn.lock
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче