@testim/testim-cli 3.289.0 → 3.290.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +1951 -203
- package/package.json +9 -5
- package/OverrideTestDataBuilder.js +0 -117
- package/agent/routers/cliJsCode/index.js +0 -13
- package/agent/routers/cliJsCode/router.js +0 -63
- package/agent/routers/cliJsCode/service.js +0 -705
- package/agent/routers/codim/router.js +0 -69
- package/agent/routers/codim/router.test.js +0 -60
- package/agent/routers/codim/service.js +0 -193
- package/agent/routers/general/index.js +0 -36
- package/agent/routers/hybrid/registerRoutes.js +0 -81
- package/agent/routers/index.js +0 -56
- package/agent/routers/playground/router.js +0 -77
- package/agent/routers/playground/service.js +0 -96
- package/agent/routers/standalone-browser/registerRoutes.js +0 -47
- package/agent/server.js +0 -150
- package/cdpTestRunner.js +0 -86
- package/chromiumInstaller.js +0 -91
- package/cli/isCiRun.js +0 -10
- package/cli/onExit.js +0 -65
- package/cli/writeStackTrace.js +0 -27
- package/cliAgentMode.js +0 -384
- package/codim/codim-cli.js +0 -91
- package/codim/codim-npm-package/index.ts +0 -427
- package/codim/codim-npm-package/package-lock.json +0 -14
- package/codim/codim-npm-package/package.json +0 -14
- package/codim/hybrid-utils.js +0 -28
- package/codim/measure-perf.js +0 -41
- package/codim/template.js/.idea/workspace.xml +0 -57
- package/codim/template.js/.vscode/launch.json +0 -53
- package/codim/template.ts/.idea/workspace.xml +0 -57
- package/codim/template.ts/.vscode/launch.json +0 -55
- package/commons/AbortError.js +0 -12
- package/commons/SeleniumPerfStats.js +0 -58
- package/commons/chrome-launcher.js +0 -15
- package/commons/chromedriverWrapper.js +0 -70
- package/commons/config.js +0 -39
- package/commons/constants.js +0 -67
- package/commons/detectDebugger.js +0 -19
- package/commons/featureAvailabilityService.js +0 -26
- package/commons/featureFlags.js +0 -132
- package/commons/getSessionPlayerRequire.js +0 -28
- package/commons/httpRequest.js +0 -261
- package/commons/httpRequestCounters.js +0 -98
- package/commons/httpRequestCounters.test.js +0 -38
- package/commons/initializeUserWithAuth.js +0 -55
- package/commons/lazyRequire.js +0 -105
- package/commons/logUtils.js +0 -15
- package/commons/logUtils.test.js +0 -21
- package/commons/logger.js +0 -178
- package/commons/mockNetworkRuleFileSchema.json +0 -140
- package/commons/npmWrapper.js +0 -174
- package/commons/npmWrapper.test.js +0 -374
- package/commons/performance-logger.js +0 -71
- package/commons/preloadTests.js +0 -29
- package/commons/prepareRunner.js +0 -85
- package/commons/prepareRunner.test.js +0 -144
- package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
- package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
- package/commons/requireWithFallback.js +0 -25
- package/commons/runnerFileCache.js +0 -204
- package/commons/socket/baseSocketServiceSocketIO.js +0 -197
- package/commons/socket/realDataService.js +0 -59
- package/commons/socket/realDataServiceSocketIO.js +0 -33
- package/commons/socket/remoteStepService.js +0 -55
- package/commons/socket/remoteStepServiceSocketIO.js +0 -61
- package/commons/socket/socketService.js +0 -175
- package/commons/socket/testResultService.js +0 -62
- package/commons/socket/testResultServiceSocketIO.js +0 -64
- package/commons/testimAnalytics.js +0 -40
- package/commons/testimCloudflare.js +0 -83
- package/commons/testimCloudflare.test.js +0 -185
- package/commons/testimCustomToken.js +0 -124
- package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
- package/commons/testimNgrok.js +0 -90
- package/commons/testimNgrok.test.js +0 -140
- package/commons/testimServicesApi.js +0 -631
- package/commons/testimTunnel.js +0 -73
- package/commons/testimTunnel.test.js +0 -172
- package/commons/xhr2.js +0 -897
- package/coverage/SummaryToObjectReport.js +0 -19
- package/coverage/jsCoverage.js +0 -252
- package/credentialsManager.js +0 -142
- package/errors.js +0 -161
- package/executionQueue.js +0 -37
- package/fixLocalBuild.js +0 -24
- package/inputFileUtils.js +0 -103
- package/lib/coralogix-winston.transport.js +0 -99
- package/player/SeleniumProtocolError.js +0 -100
- package/player/WebDriverHttpRequest.js +0 -177
- package/player/WebdriverioWebDriverApi.js +0 -671
- package/player/appiumTestPlayer.js +0 -90
- package/player/chromeLauncherTestPlayer.js +0 -67
- package/player/constants.js +0 -332
- package/player/extensionTestPlayer.js +0 -32
- package/player/findElementStrategy.js +0 -154
- package/player/scripts/isElementDisplayed.js +0 -252
- package/player/seleniumTestPlayer.js +0 -140
- package/player/services/frameLocator.js +0 -170
- package/player/services/mobileFrameLocatorMock.js +0 -32
- package/player/services/playbackTimeoutCalculator.js +0 -175
- package/player/services/portSelector.js +0 -19
- package/player/services/tabService.js +0 -551
- package/player/services/tabServiceMock.js +0 -167
- package/player/services/windowCreationListener.js +0 -8
- package/player/stepActions/RefreshStepAction.js +0 -16
- package/player/stepActions/apiStepAction.js +0 -89
- package/player/stepActions/baseCliJsStepAction.js +0 -51
- package/player/stepActions/baseJsStepAction.js +0 -277
- package/player/stepActions/cliConditionStepAction.js +0 -11
- package/player/stepActions/cliJsStepAction.js +0 -11
- package/player/stepActions/dropFileStepAction.js +0 -34
- package/player/stepActions/evaluateExpressionStepAction.js +0 -52
- package/player/stepActions/extensionOnlyStepAction.js +0 -12
- package/player/stepActions/extractTextStepAction.js +0 -19
- package/player/stepActions/hoverStepAction.js +0 -55
- package/player/stepActions/inputFileStepAction.js +0 -199
- package/player/stepActions/jsCodeStepAction.js +0 -11
- package/player/stepActions/jsConditionStepAction.js +0 -11
- package/player/stepActions/locateStepAction.js +0 -159
- package/player/stepActions/mouseStepAction.js +0 -370
- package/player/stepActions/navigationStepAction.js +0 -29
- package/player/stepActions/nodePackageStepAction.js +0 -47
- package/player/stepActions/pixelValidationStepAction.js +0 -39
- package/player/stepActions/scripts/dispatchEvents.js +0 -282
- package/player/stepActions/scripts/doClick.js +0 -221
- package/player/stepActions/scripts/doDragPath.js +0 -225
- package/player/stepActions/scripts/doubleClick.js +0 -119
- package/player/stepActions/scripts/dropEvent.js +0 -63
- package/player/stepActions/scripts/focusElement.js +0 -46
- package/player/stepActions/scripts/html5dragAction.js +0 -56
- package/player/stepActions/scripts/html5dragActionV2.js +0 -312
- package/player/stepActions/scripts/runCode.js +0 -147
- package/player/stepActions/scripts/scroll.js +0 -90
- package/player/stepActions/scripts/selectOption.js +0 -51
- package/player/stepActions/scripts/setText.js +0 -415
- package/player/stepActions/scripts/wheel.js +0 -61
- package/player/stepActions/scrollStepAction.js +0 -96
- package/player/stepActions/selectOptionStepAction.js +0 -49
- package/player/stepActions/sfdcRecordedStepAction.js +0 -24
- package/player/stepActions/sfdcStepAction.js +0 -28
- package/player/stepActions/sleepStepAction.js +0 -12
- package/player/stepActions/specialKeyStepAction.js +0 -52
- package/player/stepActions/stepAction.js +0 -73
- package/player/stepActions/stepActionRegistrar.js +0 -111
- package/player/stepActions/submitStepAction.js +0 -12
- package/player/stepActions/tdkHybridStepAction.js +0 -18
- package/player/stepActions/textStepAction.js +0 -110
- package/player/stepActions/textValidationStepAction.js +0 -64
- package/player/stepActions/wheelStepAction.js +0 -41
- package/player/utils/cookieUtils.js +0 -39
- package/player/utils/eyeSdkService.js +0 -250
- package/player/utils/imageCaptureUtils.js +0 -267
- package/player/utils/screenshotUtils.js +0 -68
- package/player/utils/stepActionUtils.js +0 -90
- package/player/utils/windowUtils.js +0 -195
- package/player/webDriverUtils.js +0 -40
- package/player/webDriverUtils.test.js +0 -116
- package/player/webdriver.js +0 -976
- package/polyfills/Array.prototype.at.js +0 -13
- package/polyfills/index.js +0 -13
- package/processHandler.js +0 -79
- package/processHandler.test.js +0 -55
- package/reports/chromeReporter.js +0 -17
- package/reports/consoleReporter.js +0 -190
- package/reports/debugReporter.js +0 -82
- package/reports/jsonReporter.js +0 -55
- package/reports/junitReporter.js +0 -183
- package/reports/reporter.js +0 -166
- package/reports/reporterUtils.js +0 -54
- package/reports/teamCityReporter.js +0 -73
- package/runOptions.d.ts +0 -305
- package/runOptions.js +0 -1288
- package/runOptionsAgentFlow.js +0 -87
- package/runOptionsUtils.js +0 -60
- package/runner.js +0 -355
- package/runners/ParallelWorkerManager.js +0 -284
- package/runners/TestPlanRunner.js +0 -419
- package/runners/buildCodeTests.js +0 -159
- package/runners/runnerUtils.js +0 -81
- package/services/analyticsService.js +0 -96
- package/services/branchService.js +0 -29
- package/services/gridService.js +0 -357
- package/services/gridService.test.js +0 -357
- package/services/labFeaturesService.js +0 -64
- package/services/lambdatestService.js +0 -227
- package/services/lambdatestService.test.js +0 -353
- package/services/localRCASaver.js +0 -124
- package/stepPlayers/cliJsStepPlayback.js +0 -40
- package/stepPlayers/hybridStepPlayback.js +0 -140
- package/stepPlayers/nodePackageStepPlayback.js +0 -28
- package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
- package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
- package/stepPlayers/remoteStepPlayback.js +0 -80
- package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
- package/stepPlayers/tdkHybridStepPlayback.js +0 -112
- package/testRunHandler.js +0 -603
- package/testRunStatus.js +0 -567
- package/testimNpmDriver.js +0 -52
- package/utils/argsUtils.js +0 -91
- package/utils/argsUtils.test.js +0 -32
- package/utils/fsUtils.js +0 -174
- package/utils/index.js +0 -197
- package/utils/promiseUtils.js +0 -85
- package/utils/stringUtils.js +0 -98
- package/utils/stringUtils.test.js +0 -22
- package/utils/timeUtils.js +0 -25
- package/utils/utils.test.js +0 -27
- package/workers/BaseWorker.js +0 -498
- package/workers/BaseWorker.test.js +0 -186
- package/workers/WorkerAppium.js +0 -180
- package/workers/WorkerExtension.js +0 -192
- package/workers/WorkerExtensionSingleBrowser.js +0 -77
- package/workers/WorkerSelenium.js +0 -253
- package/workers/workerUtils.js +0 -20
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const pRetry = require('p-retry');
|
|
6
|
-
const { delay } = require('../../utils');
|
|
7
|
-
const { PageNotAvailableError } = require('../../errors');
|
|
8
|
-
const utils = require('../../utils');
|
|
9
|
-
const logger = require('../../commons/logger').getLogger('window-utils');
|
|
10
|
-
|
|
11
|
-
class WindowUtils {
|
|
12
|
-
/**
|
|
13
|
-
* @param {number} id tab or worker id
|
|
14
|
-
* @param {import('../webdriver')} driver
|
|
15
|
-
* */
|
|
16
|
-
constructor(id, driver) {
|
|
17
|
-
this.id = id;
|
|
18
|
-
this.driver = driver;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Seems unused and not working since bad args to executeJS
|
|
22
|
-
getElementFromPoint(x, y) {
|
|
23
|
-
/* eslint-disable */
|
|
24
|
-
function elementFromPoint(x, y) {
|
|
25
|
-
var el = document.elementFromPoint(x, y);
|
|
26
|
-
return { testimId: el ? el.getAttribute('testim_dom_element_id') : null, tagName: el ? el.tagName : null };
|
|
27
|
-
}
|
|
28
|
-
/* eslint-enable */
|
|
29
|
-
|
|
30
|
-
return this.driver.executeJS(elementFromPoint, x, y).then(result => result.value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getLocation() {
|
|
34
|
-
return this.driver.getUrl();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
stopListeningToScroll() {
|
|
38
|
-
return Promise.resolve();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
resumeListeningToScroll() {
|
|
42
|
-
return Promise.resolve();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
scrollToPosition(pos) {
|
|
46
|
-
return this.driver.scroll(pos.x, pos.y);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
scrollToPositionWithoutAnimation(pos) {
|
|
50
|
-
/* eslint-disable */
|
|
51
|
-
// if scroll behavior is not supported, then the scrolling is not animated anyway
|
|
52
|
-
function scrollWithoutAnimation(position) {
|
|
53
|
-
var scrollBehaviorSupported = 'scrollBehavior' in document.documentElement.style;
|
|
54
|
-
if (scrollBehaviorSupported) {
|
|
55
|
-
return window.scrollTo({ left: position.x, top: position.y, behavior: 'instant' });
|
|
56
|
-
}
|
|
57
|
-
return window.scrollTo(position.x, position.y);
|
|
58
|
-
}
|
|
59
|
-
/* eslint-enable */
|
|
60
|
-
return this.driver.executeJS(scrollWithoutAnimation, pos);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getCurrentScrollPosition() {
|
|
64
|
-
/* eslint-disable */
|
|
65
|
-
function scrollPosition() {
|
|
66
|
-
return { x: window.scrollX, y: window.scrollY };
|
|
67
|
-
}
|
|
68
|
-
/* eslint-enable */
|
|
69
|
-
|
|
70
|
-
return this.driver.executeJS(scrollPosition).then(result => result.value);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
navigate(location, NAVIGATION_MAX_TIME = 15000) {
|
|
74
|
-
const that = this;
|
|
75
|
-
|
|
76
|
-
async function navigate(retries = 3) {
|
|
77
|
-
try {
|
|
78
|
-
await that.driver.url(location);
|
|
79
|
-
} catch (err) {
|
|
80
|
-
const shouldRetryNavigation = err.seleniumStack && err.message.includes('method IWebBrowser2::Navigate2() failed');
|
|
81
|
-
if (shouldRetryNavigation && retries > 0) {
|
|
82
|
-
logger.warn('selenium navigation failed. retrying to navigate', { err });
|
|
83
|
-
await delay(1500);
|
|
84
|
-
return navigate(retries - 1);
|
|
85
|
-
}
|
|
86
|
-
throw err;
|
|
87
|
-
}
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return Promise.race([navigate(), delay(NAVIGATION_MAX_TIME)]);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
reloadTab(timeoutMSec = 15000) {
|
|
95
|
-
return Promise.race([
|
|
96
|
-
this.driver.reloadTab(),
|
|
97
|
-
delay(timeoutMSec),
|
|
98
|
-
]);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getViewportSize() {
|
|
102
|
-
return this.driver.getViewportSize();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
maximizeWithoutValidation() {
|
|
106
|
-
return this.driver.maximizeWithoutValidation();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getFullPageSize() {
|
|
110
|
-
/* eslint-disable */
|
|
111
|
-
function fullPageSize() {
|
|
112
|
-
var body = document.body;
|
|
113
|
-
var html = document.documentElement;
|
|
114
|
-
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
115
|
-
var width = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth);
|
|
116
|
-
return {
|
|
117
|
-
height: height,
|
|
118
|
-
width: width
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/* eslint-enable */
|
|
122
|
-
|
|
123
|
-
return this.driver.executeJS(fullPageSize).then(result => result.value);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
extractToNewWindow() {
|
|
127
|
-
return Promise.resolve();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async checkSize(size) {
|
|
131
|
-
await utils.delay(1000);
|
|
132
|
-
const actualSize = await this.getViewportSize();
|
|
133
|
-
if (actualSize.width !== size.width || actualSize.height !== size.height) {
|
|
134
|
-
return Promise.reject({ actualSize, expectedSize: size });
|
|
135
|
-
}
|
|
136
|
-
return { actualSize, expectedSize: size };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async setViewportSize(size) {
|
|
140
|
-
await this.driver.setViewportSize(size.width, size.height);
|
|
141
|
-
return await this.checkSize(size);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async validatePageIsAvailable() {
|
|
145
|
-
/* eslint-disable */
|
|
146
|
-
function pageIsAvailable() {
|
|
147
|
-
var locationObj;
|
|
148
|
-
// this sometimes happens on IE
|
|
149
|
-
if (typeof location !== 'undefined') {
|
|
150
|
-
locationObj = location;
|
|
151
|
-
} else if (typeof window !== 'undefined' && typeof window.location !== 'undefined') {
|
|
152
|
-
locationObj = window.location;
|
|
153
|
-
} else {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
locationObj.href !== 'chrome-error://chromewebdata/' &&
|
|
159
|
-
locationObj.href !== 'safari-resource:/ErrorPage.html' &&
|
|
160
|
-
locationObj.href.indexOf('res://ieframe.dll/http_404.htm') !== 0 &&
|
|
161
|
-
locationObj.href.indexOf('ms-appx-web://microsoft.microsoftedge/assets/errorpages/') !== 0
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
/* eslint-enable */
|
|
165
|
-
|
|
166
|
-
const result = await this.driver.executeJS(pageIsAvailable);
|
|
167
|
-
if (!result.value) {
|
|
168
|
-
throw new PageNotAvailableError('validatePageIsAvailable:PageNotAvailableError');
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
focusTab() {
|
|
173
|
-
return this.driver.switchTab(this.id);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
quit() {
|
|
177
|
-
return undefined;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
async getOsAndBrowser() {
|
|
181
|
-
const osAndBrowser = await pRetry(() => this.driver.getBrowserAndOS(), { retries: 3 });
|
|
182
|
-
return {
|
|
183
|
-
uaBrowserName: osAndBrowser.browser,
|
|
184
|
-
uaOs: osAndBrowser.os,
|
|
185
|
-
userAgent: osAndBrowser.userAgent,
|
|
186
|
-
browserVersion: osAndBrowser.browserVersion,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
getUserAgentInfo() {
|
|
191
|
-
return pRetry(() => this.driver.getUserAgentInfo(), { retries: 3 });
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
module.exports = WindowUtils;
|
package/player/webDriverUtils.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
function isOldProtocol(err) {
|
|
2
|
-
return (
|
|
3
|
-
(err.message && err.message.match(/Command not found/)) ||
|
|
4
|
-
err.message === 'HTTP method not allowed' ||
|
|
5
|
-
err.message === 'Unknown error' ||
|
|
6
|
-
(err.message && err.message.match(/Unknown timeout type/)) ||
|
|
7
|
-
(err.seleniumStack && err.seleniumStack.type === 'UnknownCommand') ||
|
|
8
|
-
(err.message && err.message.match(/did not match a known command/)) ||
|
|
9
|
-
(err.message && err.message.match(/Server returned HTTP response code: 405 for URL/)) ||
|
|
10
|
-
(err.seleniumStack && err.seleniumStack.message === 'The arguments passed to a command are either invalid or malformed.') ||
|
|
11
|
-
err.message.match(/Invalid timeout type specified: ms/)
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function encodeForSafari(url, isSafari, logger) {
|
|
16
|
-
if (!isSafari || !url) {
|
|
17
|
-
return url;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// don't touch the URL if it has %. Technically incorrect (% alone breaks Safari),
|
|
21
|
-
// but otherwise we can break other people's URLs. Replace spaces because it's safe.
|
|
22
|
-
if (url.includes('%')) {
|
|
23
|
-
return url.replace(/ /g, '%20');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
const isAlreadyEncoded = decodeURI(url) !== url;
|
|
28
|
-
if (isAlreadyEncoded) {
|
|
29
|
-
return url;
|
|
30
|
-
}
|
|
31
|
-
return encodeURI(url);
|
|
32
|
-
} catch (err) {
|
|
33
|
-
if (logger) {
|
|
34
|
-
logger.warn('tried to encode url but failed', { err, url });
|
|
35
|
-
}
|
|
36
|
-
return url;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = { isOldProtocol, encodeForSafari };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
const expect = require('chai').expect;
|
|
2
|
-
const { encodeForSafari } = require('./webDriverUtils');
|
|
3
|
-
|
|
4
|
-
describe('url encoder', () => {
|
|
5
|
-
it('works correctly on empty string', () => {
|
|
6
|
-
const url = '';
|
|
7
|
-
const result = encodeForSafari(url, true);
|
|
8
|
-
expect(result).equal('');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('works correctly no encoding', () => {
|
|
12
|
-
const url = 'https://www.google.com';
|
|
13
|
-
const result = encodeForSafari(url, true);
|
|
14
|
-
expect(result).equal(url);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('works correctly no encoding 2', () => {
|
|
18
|
-
const url = 'https://www.google.com/';
|
|
19
|
-
const result = encodeForSafari(url, true);
|
|
20
|
-
expect(result).equal(url);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('works correctly no encoding 3', () => {
|
|
24
|
-
const badUrl = 'https://www.google.com/abc+def@#';
|
|
25
|
-
const result = encodeForSafari(badUrl);
|
|
26
|
-
expect(result).equal('https://www.google.com/abc+def@#');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('encodes spaces anyway, keeps % the same', () => {
|
|
30
|
-
const url = 'https://www.google.com/abc de f %';
|
|
31
|
-
const result = encodeForSafari(url, true);
|
|
32
|
-
expect(result).equal('https://www.google.com/abc%20de%20f%20%');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('returns input on non-url', () => {
|
|
36
|
-
const url = 'httpsw123:x/asadsd/www.google.com';
|
|
37
|
-
const result = encodeForSafari(url, true);
|
|
38
|
-
expect(result).equal(url);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('returns correctly when needing encoding', () => {
|
|
42
|
-
const url = 'https://www.google.com/abc def';
|
|
43
|
-
const result = encodeForSafari(url, true);
|
|
44
|
-
expect(result).equal('https://www.google.com/abc%20def');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('doesn\'t encode %', () => {
|
|
48
|
-
const url = 'https://www.google.com/abc%def';
|
|
49
|
-
const result = encodeForSafari(url, true);
|
|
50
|
-
expect(result).equal('https://www.google.com/abc%def');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('doesn\'t double encode', () => {
|
|
54
|
-
const url = 'https://www.google.com/abc%20def';
|
|
55
|
-
const result = encodeForSafari(url, true);
|
|
56
|
-
expect(result).equal('https://www.google.com/abc%20def');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('dont double encode %', () => {
|
|
60
|
-
const badUrl = 'https://www.google.com/abc%20def%';
|
|
61
|
-
const result = encodeForSafari(badUrl);
|
|
62
|
-
expect(result).equal('https://www.google.com/abc%20def%');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('return null on null', () => {
|
|
66
|
-
const url = null;
|
|
67
|
-
const result = encodeForSafari(url, true);
|
|
68
|
-
expect(result).equal(null);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('return undefined on undefined', () => {
|
|
72
|
-
const url = undefined;
|
|
73
|
-
const result = encodeForSafari(url, true);
|
|
74
|
-
expect(result).equal(undefined);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//// check for false
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
it('unchanged on empty string', () => {
|
|
82
|
-
const url = '';
|
|
83
|
-
const result = encodeForSafari(url, false);
|
|
84
|
-
expect(result).equal('');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('unchanged no encoding', () => {
|
|
88
|
-
const url = 'https://www.google.com';
|
|
89
|
-
const result = encodeForSafari(url, false);
|
|
90
|
-
expect(result).equal(url);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('unchanged for multiple places', () => {
|
|
94
|
-
const url = 'https://www.google.com/abc de f %';
|
|
95
|
-
const result = encodeForSafari(url, false);
|
|
96
|
-
expect(result).equal('https://www.google.com/abc de f %');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('returns unchanged input on non-url', () => {
|
|
100
|
-
const url = 'httpsw123:x/asadsd/www.google.com';
|
|
101
|
-
const result = encodeForSafari(url, false);
|
|
102
|
-
expect(result).equal(url);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('returns unchanged when needing encoding', () => {
|
|
106
|
-
const url = 'https://www.google.com/abc def';
|
|
107
|
-
const result = encodeForSafari(url, false);
|
|
108
|
-
expect(result).equal('https://www.google.com/abc def');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('returns unchanged when needing encoding only %', () => {
|
|
112
|
-
const url = 'https://www.google.com/abc%def';
|
|
113
|
-
const result = encodeForSafari(url, false);
|
|
114
|
-
expect(result).equal('https://www.google.com/abc%def');
|
|
115
|
-
});
|
|
116
|
-
});
|