Skip to content

Commit

Permalink
style(other): fix linting errors
Browse files Browse the repository at this point in the history
fix linting errors
  • Loading branch information
JagadeeshKaricherla-branch committed Nov 29, 2023
1 parent 1a1bea2 commit 6fc5bbd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/5_banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ banner = function(branch, options, linkData, storage) {

var doc = options.iframe ? element.contentWindow.document : document;
var platform = utils.getPlatformByUserAgent();
if (!["other", "desktop"].includes(platform)) {
if (![ "other", "desktop" ].includes(platform)) {
options['open_app'] = options.open_app;
options['append_deeplink_path'] = options.append_deeplink_path;
options['make_new_link'] = options.make_new_link;
Expand Down
2 changes: 1 addition & 1 deletion src/6_branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ Branch.prototype['closeJourney'] = wrap(callback_params.CALLBACK_ERR, function(d

Branch.prototype['banner'] = wrap(callback_params.CALLBACK_ERR, function(done, options, data) {
var platform = utils.getPlatformByUserAgent();
if (["other", "desktop"].includes(platform)) {
if ([ "other", "desktop" ].includes(platform)) {
console.info("banner functionality is not supported on this platform");
}
else {
Expand Down
66 changes: 33 additions & 33 deletions test/1_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1237,88 +1237,88 @@ describe('utils', function() {
var originalScreenWidth = screen.width;
var userAgentsList = {
android_chrome: {
ua:'Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.163 Mobile Safari/537.36',
platform:'android'
ua: 'Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.163 Mobile Safari/537.36',
platform: 'android'
},
iOS_safari: {
ua:'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1',
platform:'ios'
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1',
platform: 'ios'
},
iOS_chrome: {
ua:'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.169 Mobile/15E148 Safari/604.1',
platform:'ios'
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.169 Mobile/15E148 Safari/604.1',
platform: 'ios'
},
iOS_ipad_safari: {
ua:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15',
platform:'ipad'
ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15',
platform: 'ipad'
},
macOS_safari: {
ua:'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15',
platform:'desktop'
ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15',
platform: 'desktop'
},
macOS_chrome: {
ua:'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
platform:'desktop'
ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
platform: 'desktop'
},
windows_edge: {
ua:'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.2151.93',
platform:'desktop'
ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.2151.93',
platform: 'desktop'
},
windows_chrome: {
ua:'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
platform:'desktop'
ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
platform: 'desktop'
},
linux_chrome: {
ua:'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
platform:'desktop'
ua: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
platform: 'desktop'
}

};

function setUserAgent(ua) {
Object.defineProperty(window.navigator, 'userAgent', {value : ua});
Object.defineProperty(window.navigator, 'userAgent', { value: ua });
}

afterEach(function() {
setUserAgent(originalUa);
Object.defineProperty(window.screen, 'width', {writable: true, configurable: true, value : originalScreenWidth});
Object.defineProperty(window.screen, 'height', {writable: true, configurable: true, value : originalScreenHeight});
Object.defineProperty(window.screen, 'width', { writable: true, configurable: true, value: originalScreenWidth });
Object.defineProperty(window.screen, 'height', { writable: true, configurable: true, value: originalScreenHeight });
});
it('should return "android" for Android chrome user agent', function () {
it('should return "android" for Android chrome user agent', function() {
setUserAgent(userAgentsList.android_chrome.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.android_chrome.platform);
});
it('should return "ios" for ios safari user agent', function () {
it('should return "ios" for ios safari user agent', function() {
setUserAgent(userAgentsList.iOS_safari.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.iOS_safari.platform);
});
it('should return "ios" for ios chrome user agent', function () {
it('should return "ios" for ios chrome user agent', function() {
setUserAgent(userAgentsList.iOS_chrome.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.iOS_chrome.platform);
});
it('should return "ipad" for iOS ipad safari user agent', function () {
it('should return "ipad" for iOS ipad safari user agent', function() {
setUserAgent(userAgentsList.iOS_ipad_safari.ua);
Object.defineProperty(window.screen, 'width', {writable: true, configurable: true, value : 1024});
Object.defineProperty(window.screen, 'height', {writable: true, configurable: true, value : 1366});
Object.defineProperty(window.screen, 'width', { writable: true, configurable: true, value: 1024 });
Object.defineProperty(window.screen, 'height', { writable: true, configurable: true, value: 1366 });
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.iOS_ipad_safari.platform);
});
it('should return "desktop" for macOS safari user agent', function () {
it('should return "desktop" for macOS safari user agent', function() {
setUserAgent(userAgentsList.macOS_safari.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.macOS_safari.platform);
});
it('should return "desktop" for macOS chrome user agent', function () {
it('should return "desktop" for macOS chrome user agent', function() {
setUserAgent(userAgentsList.macOS_chrome.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.macOS_chrome.platform);
});
it('should return "desktop" for windows edge user agent', function () {
it('should return "desktop" for windows edge user agent', function() {
setUserAgent(userAgentsList.windows_edge.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.windows_edge.platform);
});
it('should return "desktop" for windows chrome user agent', function () {
it('should return "desktop" for windows chrome user agent', function() {
setUserAgent(userAgentsList.windows_chrome.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.windows_chrome.platform);
});
it('should return "desktop" for linux chrome user agent', function () {
it('should return "desktop" for linux chrome user agent', function() {
setUserAgent(userAgentsList.linux_chrome.ua);
assert.equal(utils.getPlatformByUserAgent(), userAgentsList.linux_chrome.platform);
});
Expand Down

0 comments on commit 6fc5bbd

Please sign in to comment.