@microsoft/1ds-core-js 3.1.3 → 3.1.7
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/README.md +1 -1
- package/bundle/ms.core-3.1.7.gbl.js +3589 -0
- package/bundle/ms.core-3.1.7.gbl.js.map +1 -0
- package/bundle/ms.core-3.1.7.gbl.min.js +7 -0
- package/bundle/ms.core-3.1.7.gbl.min.js.map +1 -0
- package/bundle/ms.core-3.1.7.integrity.json +46 -0
- package/bundle/{ms.core-test.js → ms.core-3.1.7.js} +203 -100
- package/bundle/ms.core-3.1.7.js.map +1 -0
- package/bundle/ms.core-3.1.7.min.js +7 -0
- package/bundle/ms.core-3.1.7.min.js.map +1 -0
- package/bundle/{ms.core-3.1.3.gbl.js → ms.core.gbl.js} +201 -98
- package/bundle/ms.core.gbl.js.map +1 -0
- package/bundle/ms.core.gbl.min.js +7 -0
- package/bundle/ms.core.gbl.min.js.map +1 -0
- package/bundle/ms.core.integrity.json +46 -0
- package/bundle/{ms.core-3.1.3.js → ms.core.js} +202 -99
- package/bundle/ms.core.js.map +1 -0
- package/bundle/ms.core.min.js +7 -0
- package/bundle/ms.core.min.js.map +1 -0
- package/dist/ms.core.js +64 -68
- package/dist/ms.core.js.map +1 -1
- package/dist/ms.core.min.js +2 -2
- package/dist/ms.core.min.js.map +1 -1
- package/dist-esm/src/AppInsightsCore.js +1 -1
- package/dist-esm/src/BaseCore.js +1 -1
- package/dist-esm/src/DataModels.d.ts +5 -2
- package/dist-esm/src/DataModels.js +2 -1
- package/dist-esm/src/DataModels.js.map +1 -1
- package/dist-esm/src/ESPromise.js +1 -1
- package/dist-esm/src/ESPromiseScheduler.js +1 -1
- package/dist-esm/src/Enums.d.ts +1 -0
- package/dist-esm/src/Enums.js +1 -1
- package/dist-esm/src/Index.d.ts +4 -3
- package/dist-esm/src/Index.js +6 -5
- package/dist-esm/src/Index.js.map +1 -1
- package/dist-esm/src/Utils.d.ts +33 -19
- package/dist-esm/src/Utils.js +86 -75
- package/dist-esm/src/Utils.js.map +1 -1
- package/dist-esm/src/ValueSanitizer.js +1 -1
- package/package.json +6 -6
- package/src/DataModels.ts +5 -2
- package/src/Index.ts +10 -10
- package/src/Utils.ts +100 -84
- package/tsconfig.json +2 -4
- package/bundle/ms.core-3.1.3.gbl.js.map +0 -1
- package/bundle/ms.core-3.1.3.gbl.min.js +0 -7
- package/bundle/ms.core-3.1.3.gbl.min.js.map +0 -1
- package/bundle/ms.core-3.1.3.js.map +0 -1
- package/bundle/ms.core-3.1.3.min.js +0 -7
- package/bundle/ms.core-3.1.3.min.js.map +0 -1
- package/bundle/ms.core-test.js.map +0 -1
- package/bundle/ms.core-test.min.js +0 -7
- package/bundle/ms.core-test.min.js.map +0 -1
- package/dist-esm/test/CoreTest.d.ts +0 -6
- package/dist-esm/test/CoreTest.js +0 -105
- package/dist-esm/test/CoreTest.js.map +0 -1
- package/dist-esm/test/DynamicProtoTests.d.ts +0 -7
- package/dist-esm/test/DynamicProtoTests.js +0 -541
- package/dist-esm/test/DynamicProtoTests.js.map +0 -1
- package/dist-esm/test/ESPromiseSchedulerTests.d.ts +0 -6
- package/dist-esm/test/ESPromiseSchedulerTests.js +0 -190
- package/dist-esm/test/ESPromiseSchedulerTests.js.map +0 -1
- package/dist-esm/test/ESPromiseTests.d.ts +0 -5
- package/dist-esm/test/ESPromiseTests.js +0 -422
- package/dist-esm/test/ESPromiseTests.js.map +0 -1
- package/dist-esm/test/FileSizeCheckTest.d.ts +0 -5
- package/dist-esm/test/FileSizeCheckTest.js +0 -42
- package/dist-esm/test/FileSizeCheckTest.js.map +0 -1
- package/dist-esm/test/Index.d.ts +0 -1
- package/dist-esm/test/Index.js +0 -23
- package/dist-esm/test/Index.js.map +0 -1
- package/dist-esm/test/TestClass.d.ts +0 -103
- package/dist-esm/test/TestClass.js +0 -396
- package/dist-esm/test/TestClass.js.map +0 -1
- package/dist-esm/test/TestHelper.d.ts +0 -7
- package/dist-esm/test/TestHelper.js +0 -98
- package/dist-esm/test/TestHelper.js.map +0 -1
- package/dist-esm/test/UtilsTest.d.ts +0 -4
- package/dist-esm/test/UtilsTest.js +0 -224
- package/dist-esm/test/UtilsTest.js.map +0 -1
- package/dist-esm/test/ValueSanitizerTests.d.ts +0 -6
- package/dist-esm/test/ValueSanitizerTests.js +0 -331
- package/dist-esm/test/ValueSanitizerTests.js.map +0 -1
- package/src/typings/XDomainRequest.d.ts +0 -23
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { SinonSandbox, SinonSpy, SinonStub, SinonMock, SinonSandboxConfig } from 'sinon';
|
|
2
|
-
import ESPromise from '../src/ESPromise';
|
|
3
|
-
export interface FakeXMLHttpRequest extends XMLHttpRequest {
|
|
4
|
-
url?: string;
|
|
5
|
-
method?: string;
|
|
6
|
-
requestHeaders?: any;
|
|
7
|
-
respond: (status: number, headers: any, body: string) => void;
|
|
8
|
-
}
|
|
9
|
-
/** Defines a test case */
|
|
10
|
-
export declare class TestCase {
|
|
11
|
-
/** Name to use for the test case */
|
|
12
|
-
name: string;
|
|
13
|
-
useFakeServer?: boolean;
|
|
14
|
-
useFakeTimers?: boolean;
|
|
15
|
-
/** Test case method */
|
|
16
|
-
test: () => void | ESPromise<any>;
|
|
17
|
-
/** We expect the test to complete within this interval (defaults to 5 seconds) */
|
|
18
|
-
timeout?: number;
|
|
19
|
-
/** Used for debugging, set this value to ignore the automatic timeout for tests that return a promise */
|
|
20
|
-
skipTimeout?: boolean;
|
|
21
|
-
}
|
|
22
|
-
/** Defines a test case */
|
|
23
|
-
export interface TestCaseAsync {
|
|
24
|
-
/** Name to use for the test case */
|
|
25
|
-
name: string;
|
|
26
|
-
useFakeServer?: boolean;
|
|
27
|
-
useFakeTimers?: boolean;
|
|
28
|
-
/** time to wait after pre before invoking post and calling start() */
|
|
29
|
-
stepDelay: number;
|
|
30
|
-
/** async steps */
|
|
31
|
-
steps: Array<(done?: VoidFunction) => void>;
|
|
32
|
-
/**
|
|
33
|
-
* Terminate and fail the test if it runs longer than this
|
|
34
|
-
*/
|
|
35
|
-
timeOut?: number;
|
|
36
|
-
/**
|
|
37
|
-
* Flag which specifies that once all of the steps are completed the test case is completed.
|
|
38
|
-
* True by default
|
|
39
|
-
*/
|
|
40
|
-
autoComplete?: boolean;
|
|
41
|
-
}
|
|
42
|
-
export declare class TestClass {
|
|
43
|
-
constructor(name?: string);
|
|
44
|
-
static isPollingStepFlag: string;
|
|
45
|
-
/** The instance of the currently running suite. */
|
|
46
|
-
static currentTestClass: TestClass;
|
|
47
|
-
/** Turns on/off sinon's fake implementation of XMLHttpRequest. On by default. */
|
|
48
|
-
sandboxConfig: SinonSandboxConfig;
|
|
49
|
-
static orgSetTimeout: (handler: Function, timeout?: number) => number;
|
|
50
|
-
static orgClearTimeout: (handle?: number) => void;
|
|
51
|
-
protected _xhrRequests: FakeXMLHttpRequest[];
|
|
52
|
-
protected _clock: any;
|
|
53
|
-
private _xhr;
|
|
54
|
-
private _orgNavigator;
|
|
55
|
-
private _beaconHooks;
|
|
56
|
-
private _dynProtoOpts;
|
|
57
|
-
/** Method called before the start of each test method */
|
|
58
|
-
testInitialize(): void;
|
|
59
|
-
/** Method called after each test method has completed */
|
|
60
|
-
testCleanup(): void;
|
|
61
|
-
/** Method in which test class intances should call this.testCase(...) to register each of this suite's tests. */
|
|
62
|
-
registerTests(): void;
|
|
63
|
-
/** Register an async Javascript unit testcase. */
|
|
64
|
-
testCaseAsync(testInfo: TestCaseAsync): void;
|
|
65
|
-
/** Register a Javascript unit testcase. */
|
|
66
|
-
testCase(testInfo: TestCase): void;
|
|
67
|
-
protected _deleteAllCookies(): void;
|
|
68
|
-
protected _disableDynProtoBaseFuncs(): void;
|
|
69
|
-
/** Called when the test is starting. */
|
|
70
|
-
private _testStarting;
|
|
71
|
-
/** Called when the test is completed. */
|
|
72
|
-
private _testCompleted;
|
|
73
|
-
private _removeFuncHooks;
|
|
74
|
-
private _removeHooks;
|
|
75
|
-
private _cleanupAllHooks;
|
|
76
|
-
/**** Sinon methods and properties ***/
|
|
77
|
-
sandbox: SinonSandbox;
|
|
78
|
-
/** Creates an anonymous function that records arguments, this value, exceptions and return values for all calls. */
|
|
79
|
-
spy(): SinonSpy;
|
|
80
|
-
/** Spies on the provided function */
|
|
81
|
-
spy(funcToWrap: Function): SinonSpy;
|
|
82
|
-
/** Creates a spy for object.methodName and replaces the original method with the spy. The spy acts exactly like the original method in all cases. The original method can be restored by calling object.methodName.restore(). The returned spy is the function object which replaced the original method. spy === object.method. */
|
|
83
|
-
spy(object: any, methodName: string, func?: Function): SinonSpy;
|
|
84
|
-
/** Creates an anonymous stub function. */
|
|
85
|
-
stub(): SinonStub;
|
|
86
|
-
/** Stubs all the object's methods. */
|
|
87
|
-
stub(object: any): SinonStub;
|
|
88
|
-
/** Replaces object.methodName with a func, wrapped in a spy. As usual, object.methodName.restore(); can be used to restore the original method. */
|
|
89
|
-
stub(object: any, methodName: string, func?: Function): SinonStub;
|
|
90
|
-
/** Creates a mock for the provided object.Does not change the object, but returns a mock object to set expectations on the object's methods. */
|
|
91
|
-
mock(object: any): SinonMock;
|
|
92
|
-
/**** end: Sinon methods and properties ***/
|
|
93
|
-
protected setUserAgent(userAgent: string): void;
|
|
94
|
-
protected hookSendBeacon(cb: (url: string, data?: BodyInit | null) => void): void;
|
|
95
|
-
protected setNavigator(newNavigator: any): void;
|
|
96
|
-
/**
|
|
97
|
-
* Sends a JSON response to the provided request.
|
|
98
|
-
* @param request The request to respond to.
|
|
99
|
-
* @param data Data to respond with.
|
|
100
|
-
* @param errorCode Optional error code to send with the request, default is 200
|
|
101
|
-
*/
|
|
102
|
-
sendJsonResponse(request: FakeXMLHttpRequest, data: any, errorCode?: number): void;
|
|
103
|
-
}
|
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 1DS JS SDK Core, 3.1.3
|
|
3
|
-
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
-
* (Microsoft Internal Only)
|
|
5
|
-
*/
|
|
6
|
-
import dynamicProto from '@microsoft/dynamicproto-js';
|
|
7
|
-
import * as sinon from 'sinon';
|
|
8
|
-
import ESPromise from '../src/ESPromise';
|
|
9
|
-
import { arrForEach, objKeys } from '@microsoft/applicationinsights-core-js';
|
|
10
|
-
/** Defines a test case */
|
|
11
|
-
var TestCase = /** @class */ (function () {
|
|
12
|
-
function TestCase() {
|
|
13
|
-
}
|
|
14
|
-
return TestCase;
|
|
15
|
-
}());
|
|
16
|
-
export { TestCase };
|
|
17
|
-
var TestClass = /** @class */ (function () {
|
|
18
|
-
function TestClass(name) {
|
|
19
|
-
/** Turns on/off sinon's fake implementation of XMLHttpRequest. On by default. */
|
|
20
|
-
this.sandboxConfig = {};
|
|
21
|
-
this._xhrRequests = [];
|
|
22
|
-
this._clock = null;
|
|
23
|
-
this._beaconHooks = [];
|
|
24
|
-
this._dynProtoOpts = null;
|
|
25
|
-
QUnit.module(name);
|
|
26
|
-
this.sandboxConfig.injectInto = null;
|
|
27
|
-
this.sandboxConfig.properties = ["spy", "stub", "mock", "sandbox"];
|
|
28
|
-
}
|
|
29
|
-
/** Method called before the start of each test method */
|
|
30
|
-
TestClass.prototype.testInitialize = function () {
|
|
31
|
-
};
|
|
32
|
-
/** Method called after each test method has completed */
|
|
33
|
-
TestClass.prototype.testCleanup = function () {
|
|
34
|
-
};
|
|
35
|
-
/** Method in which test class intances should call this.testCase(...) to register each of this suite's tests. */
|
|
36
|
-
TestClass.prototype.registerTests = function () {
|
|
37
|
-
};
|
|
38
|
-
/** Register an async Javascript unit testcase. */
|
|
39
|
-
TestClass.prototype.testCaseAsync = function (testInfo) {
|
|
40
|
-
var _this = this;
|
|
41
|
-
if (!testInfo.name) {
|
|
42
|
-
throw new Error("Must specify name in testInfo context in registerTestcase call");
|
|
43
|
-
}
|
|
44
|
-
if (isNaN(testInfo.stepDelay)) {
|
|
45
|
-
throw new Error("Must specify 'stepDelay' period between pre and post");
|
|
46
|
-
}
|
|
47
|
-
if (!testInfo.steps) {
|
|
48
|
-
throw new Error("Must specify 'steps' to take asynchronously");
|
|
49
|
-
}
|
|
50
|
-
if (testInfo.autoComplete === undefined) {
|
|
51
|
-
testInfo.autoComplete = true;
|
|
52
|
-
}
|
|
53
|
-
// Create a wrapper around the test method so we can do test initilization and cleanup.
|
|
54
|
-
var testMethod = function (assert) {
|
|
55
|
-
var done = assert.async();
|
|
56
|
-
// Save off the instance of the currently running suite.
|
|
57
|
-
TestClass.currentTestClass = _this;
|
|
58
|
-
// Save the real clearTimeout (as _testStarting and enable sinon fake timers)
|
|
59
|
-
var orgClearTimeout = clearTimeout;
|
|
60
|
-
var orgSetTimeout = setTimeout;
|
|
61
|
-
TestClass.orgSetTimeout = function (handler, timeout) {
|
|
62
|
-
return orgSetTimeout(handler, timeout);
|
|
63
|
-
};
|
|
64
|
-
TestClass.orgClearTimeout = function (handler) {
|
|
65
|
-
orgClearTimeout(handler);
|
|
66
|
-
};
|
|
67
|
-
if (testInfo.useFakeServer) {
|
|
68
|
-
_this._xhr = sinon.useFakeXMLHttpRequest();
|
|
69
|
-
_this._xhrRequests = [];
|
|
70
|
-
_this._xhr.onCreate = function (xhr) {
|
|
71
|
-
_this._xhrRequests.push(xhr);
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (testInfo.useFakeTimers) {
|
|
75
|
-
_this._clock = sinon.useFakeTimers();
|
|
76
|
-
}
|
|
77
|
-
// Run the test.
|
|
78
|
-
try {
|
|
79
|
-
var self_1 = _this;
|
|
80
|
-
var testComplete_1 = false;
|
|
81
|
-
var timeOutTimer_1 = null;
|
|
82
|
-
var testDone_1 = function () {
|
|
83
|
-
if (timeOutTimer_1) {
|
|
84
|
-
orgClearTimeout(timeOutTimer_1);
|
|
85
|
-
}
|
|
86
|
-
testComplete_1 = true;
|
|
87
|
-
// done is QUnit callback indicating the end of the test
|
|
88
|
-
self_1._testCompleted();
|
|
89
|
-
done();
|
|
90
|
-
};
|
|
91
|
-
if (testInfo.timeOut !== undefined) {
|
|
92
|
-
timeOutTimer_1 = orgSetTimeout(function () {
|
|
93
|
-
QUnit.assert.ok(false, "Test case timed out!");
|
|
94
|
-
testComplete_1 = true;
|
|
95
|
-
done();
|
|
96
|
-
}, testInfo.timeOut);
|
|
97
|
-
}
|
|
98
|
-
_this._testStarting();
|
|
99
|
-
var steps_1 = testInfo.steps;
|
|
100
|
-
var trigger_1 = function () {
|
|
101
|
-
// The callback which activates the next test step.
|
|
102
|
-
var nextTestStepTrigger = function () {
|
|
103
|
-
orgSetTimeout(function () {
|
|
104
|
-
trigger_1();
|
|
105
|
-
}, testInfo.stepDelay);
|
|
106
|
-
};
|
|
107
|
-
if (steps_1.length && !testComplete_1) {
|
|
108
|
-
var step = steps_1.shift();
|
|
109
|
-
// There 2 types of test steps - simple and polling.
|
|
110
|
-
// Upon completion of the simple test step the next test step will be called.
|
|
111
|
-
// In case of polling test step the next test step is passed to the polling test step, and
|
|
112
|
-
// it is responsibility of the polling test step to call the next test step.
|
|
113
|
-
try {
|
|
114
|
-
if (step) {
|
|
115
|
-
if (step[TestClass.isPollingStepFlag]) {
|
|
116
|
-
step.call(_this, nextTestStepTrigger);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
step.call(_this, testDone_1);
|
|
120
|
-
nextTestStepTrigger.call(_this);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (e) {
|
|
125
|
-
QUnit.assert.ok(false, e.toString());
|
|
126
|
-
// done is QUnit callback indicating the end of the test
|
|
127
|
-
testDone_1();
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else if (!testComplete_1) {
|
|
132
|
-
if (testInfo.autoComplete) {
|
|
133
|
-
// done is QUnit callback indicating the end of the test
|
|
134
|
-
testDone_1();
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
nextTestStepTrigger();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
trigger_1();
|
|
142
|
-
}
|
|
143
|
-
catch (ex) {
|
|
144
|
-
QUnit.assert.ok(false, "Unexpected Exception: " + ex);
|
|
145
|
-
_this._testCompleted(true);
|
|
146
|
-
// done is QUnit callback indicating the end of the test
|
|
147
|
-
done();
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
// Register the test with QUnit
|
|
151
|
-
QUnit.test(testInfo.name, testMethod);
|
|
152
|
-
};
|
|
153
|
-
/** Register a Javascript unit testcase. */
|
|
154
|
-
TestClass.prototype.testCase = function (testInfo) {
|
|
155
|
-
var _this = this;
|
|
156
|
-
if (!testInfo.name) {
|
|
157
|
-
throw new Error("Must specify name in testInfo context in registerTestcase call");
|
|
158
|
-
}
|
|
159
|
-
if (!testInfo.test) {
|
|
160
|
-
throw new Error("Must specify 'test' method in testInfo context in registerTestcase call");
|
|
161
|
-
}
|
|
162
|
-
// Create a wrapper around the test method so we can do test initilization and cleanup.
|
|
163
|
-
var testMethod = function (assert) {
|
|
164
|
-
var done = assert.async();
|
|
165
|
-
// Save off the instance of the currently running suite.
|
|
166
|
-
TestClass.currentTestClass = _this;
|
|
167
|
-
function _testFinished(failed) {
|
|
168
|
-
TestClass.currentTestClass._testCompleted(failed);
|
|
169
|
-
done();
|
|
170
|
-
}
|
|
171
|
-
// Save the real clearTimeout (as _testStarting and enable sinon fake timers)
|
|
172
|
-
var orgClearTimeout = clearTimeout;
|
|
173
|
-
var orgSetTimeout = setTimeout;
|
|
174
|
-
TestClass.orgSetTimeout = function (handler, timeout) {
|
|
175
|
-
return orgSetTimeout(handler, timeout);
|
|
176
|
-
};
|
|
177
|
-
TestClass.orgClearTimeout = function (handler) {
|
|
178
|
-
orgClearTimeout(handler);
|
|
179
|
-
};
|
|
180
|
-
if (testInfo.useFakeServer) {
|
|
181
|
-
_this._xhr = sinon.useFakeXMLHttpRequest();
|
|
182
|
-
_this._xhrRequests = [];
|
|
183
|
-
_this._xhr.onCreate = function (xhr) {
|
|
184
|
-
_this._xhrRequests.push(xhr);
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
if (testInfo.useFakeTimers) {
|
|
188
|
-
_this._clock = sinon.useFakeTimers();
|
|
189
|
-
}
|
|
190
|
-
// Run the test.
|
|
191
|
-
try {
|
|
192
|
-
_this._testStarting();
|
|
193
|
-
var result = testInfo.test.call(_this);
|
|
194
|
-
if (result instanceof ESPromise) {
|
|
195
|
-
var promiseTimeout_1 = null;
|
|
196
|
-
if (testInfo.skipTimeout !== true) {
|
|
197
|
-
var timeout_1 = testInfo.timeout || 5000;
|
|
198
|
-
promiseTimeout_1 = setTimeout(function () {
|
|
199
|
-
QUnit.assert.ok(false, "Timeout: Aborting as the Promise returned from the test method did not resolve within " + timeout_1 + " ms");
|
|
200
|
-
_testFinished(true);
|
|
201
|
-
}, timeout_1);
|
|
202
|
-
}
|
|
203
|
-
result.then(function () {
|
|
204
|
-
promiseTimeout_1 && clearTimeout(promiseTimeout_1);
|
|
205
|
-
_testFinished();
|
|
206
|
-
}, function (reason) {
|
|
207
|
-
promiseTimeout_1 && clearTimeout(promiseTimeout_1);
|
|
208
|
-
QUnit.assert.ok(false, "Returned Promise rejected: " + reason);
|
|
209
|
-
_testFinished(true);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
_testFinished();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
catch (ex) {
|
|
217
|
-
QUnit.assert.ok(false, "Unexpected Exception: " + ex);
|
|
218
|
-
_testFinished(true);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
// Register the test with QUnit
|
|
222
|
-
QUnit.test(testInfo.name, testMethod);
|
|
223
|
-
};
|
|
224
|
-
TestClass.prototype._deleteAllCookies = function () {
|
|
225
|
-
var cookies = document.cookie.split(";");
|
|
226
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
227
|
-
var cookie = cookies[i];
|
|
228
|
-
var eqPos = cookie.indexOf("=");
|
|
229
|
-
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
|
230
|
-
document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
TestClass.prototype._disableDynProtoBaseFuncs = function () {
|
|
234
|
-
var _this = this;
|
|
235
|
-
var defOpts = dynamicProto['_dfOpts'];
|
|
236
|
-
if (defOpts) {
|
|
237
|
-
if (!this._dynProtoOpts) {
|
|
238
|
-
// Save the current settings so we can restore them
|
|
239
|
-
this._dynProtoOpts = {};
|
|
240
|
-
arrForEach(objKeys(defOpts), function (key) {
|
|
241
|
-
_this._dynProtoOpts[key] = defOpts[key];
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
defOpts.useBaseInst = false;
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
/** Called when the test is starting. */
|
|
248
|
-
TestClass.prototype._testStarting = function () {
|
|
249
|
-
this.sandbox = sinon.createSandbox(this.sandboxConfig);
|
|
250
|
-
// Allow the derived class to perform test initialization.
|
|
251
|
-
this.testInitialize();
|
|
252
|
-
};
|
|
253
|
-
/** Called when the test is completed. */
|
|
254
|
-
TestClass.prototype._testCompleted = function (failed) {
|
|
255
|
-
var _this = this;
|
|
256
|
-
if (this._xhr) {
|
|
257
|
-
this._xhr.restore();
|
|
258
|
-
this._xhr = null;
|
|
259
|
-
}
|
|
260
|
-
if (this._clock) {
|
|
261
|
-
this._clock.restore();
|
|
262
|
-
this._clock = null;
|
|
263
|
-
}
|
|
264
|
-
if (this._orgNavigator) {
|
|
265
|
-
this.setNavigator(this._orgNavigator);
|
|
266
|
-
this._orgNavigator = null;
|
|
267
|
-
}
|
|
268
|
-
if (this._dynProtoOpts) {
|
|
269
|
-
var defOpts_1 = dynamicProto['_dfOpts'];
|
|
270
|
-
arrForEach(objKeys(this._dynProtoOpts), function (key) {
|
|
271
|
-
defOpts_1[key] = _this._dynProtoOpts[key];
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
this._beaconHooks = [];
|
|
275
|
-
this._cleanupAllHooks();
|
|
276
|
-
if (failed) {
|
|
277
|
-
// Just cleanup the sandbox since the test has already failed.
|
|
278
|
-
this.sandbox.restore();
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
// Verify the sandbox and restore.
|
|
282
|
-
this.sandbox.verifyAndRestore();
|
|
283
|
-
}
|
|
284
|
-
this.testCleanup();
|
|
285
|
-
// Clear the instance of the currently running suite.
|
|
286
|
-
TestClass.currentTestClass = null;
|
|
287
|
-
};
|
|
288
|
-
TestClass.prototype._removeFuncHooks = function (fn) {
|
|
289
|
-
if (typeof fn === "function") {
|
|
290
|
-
var aiHook = fn["_aiHooks"];
|
|
291
|
-
if (aiHook && aiHook.h) {
|
|
292
|
-
aiHook.h = [];
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
TestClass.prototype._removeHooks = function (target) {
|
|
297
|
-
var _this = this;
|
|
298
|
-
Object.keys(target).forEach(function (name) {
|
|
299
|
-
try {
|
|
300
|
-
_this._removeFuncHooks(target[name]);
|
|
301
|
-
}
|
|
302
|
-
catch (e) {
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
|
-
TestClass.prototype._cleanupAllHooks = function () {
|
|
307
|
-
this._removeHooks(XMLHttpRequest.prototype);
|
|
308
|
-
this._removeHooks(XMLHttpRequest);
|
|
309
|
-
this._removeFuncHooks(window.fetch);
|
|
310
|
-
};
|
|
311
|
-
TestClass.prototype.spy = function () {
|
|
312
|
-
var args = [];
|
|
313
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
314
|
-
args[_i] = arguments[_i];
|
|
315
|
-
}
|
|
316
|
-
return null;
|
|
317
|
-
};
|
|
318
|
-
TestClass.prototype.stub = function () {
|
|
319
|
-
var args = [];
|
|
320
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
321
|
-
args[_i] = arguments[_i];
|
|
322
|
-
}
|
|
323
|
-
return null;
|
|
324
|
-
};
|
|
325
|
-
/** Creates a mock for the provided object.Does not change the object, but returns a mock object to set expectations on the object's methods. */
|
|
326
|
-
TestClass.prototype.mock = function (object) { return null; };
|
|
327
|
-
/**** end: Sinon methods and properties ***/
|
|
328
|
-
TestClass.prototype.setUserAgent = function (userAgent) {
|
|
329
|
-
// Hook Send beacon which also mocks navigator
|
|
330
|
-
this.hookSendBeacon(null);
|
|
331
|
-
Object.defineProperty(window.navigator, 'userAgent', {
|
|
332
|
-
configurable: true,
|
|
333
|
-
get: function () {
|
|
334
|
-
return userAgent;
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
};
|
|
338
|
-
TestClass.prototype.hookSendBeacon = function (cb) {
|
|
339
|
-
var _this = this;
|
|
340
|
-
if (!this._orgNavigator) {
|
|
341
|
-
var newNavigator = {};
|
|
342
|
-
this._orgNavigator = window.navigator;
|
|
343
|
-
newNavigator.sendBeacon = function (url, body) {
|
|
344
|
-
_this._beaconHooks.forEach(function (element) {
|
|
345
|
-
element(url, body);
|
|
346
|
-
});
|
|
347
|
-
return _this._orgNavigator.sendBeacon(url, body);
|
|
348
|
-
};
|
|
349
|
-
var _loop_1 = function (name_1) {
|
|
350
|
-
if (!newNavigator.hasOwnProperty(name_1)) {
|
|
351
|
-
newNavigator[name_1] = navigator[name_1];
|
|
352
|
-
if (!newNavigator.hasOwnProperty(name_1)) {
|
|
353
|
-
// if it couldn't be set directly try and pretend
|
|
354
|
-
Object.defineProperty(newNavigator, name_1, {
|
|
355
|
-
configurable: true,
|
|
356
|
-
get: function () {
|
|
357
|
-
return navigator[name_1];
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
// Just Blindly copy the properties over
|
|
364
|
-
// tslint:disable-next-line: forin
|
|
365
|
-
for (var name_1 in navigator) {
|
|
366
|
-
_loop_1(name_1);
|
|
367
|
-
}
|
|
368
|
-
this.setNavigator(newNavigator);
|
|
369
|
-
}
|
|
370
|
-
this._beaconHooks.push(cb);
|
|
371
|
-
};
|
|
372
|
-
TestClass.prototype.setNavigator = function (newNavigator) {
|
|
373
|
-
Object.defineProperty(window, 'navigator', {
|
|
374
|
-
configurable: true,
|
|
375
|
-
get: function () {
|
|
376
|
-
return newNavigator;
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* Sends a JSON response to the provided request.
|
|
382
|
-
* @param request The request to respond to.
|
|
383
|
-
* @param data Data to respond with.
|
|
384
|
-
* @param errorCode Optional error code to send with the request, default is 200
|
|
385
|
-
*/
|
|
386
|
-
TestClass.prototype.sendJsonResponse = function (request, data, errorCode) {
|
|
387
|
-
if (errorCode === undefined) {
|
|
388
|
-
errorCode = 200;
|
|
389
|
-
}
|
|
390
|
-
request.respond(errorCode, { "Content-Type": "application/json" }, JSON.stringify(data));
|
|
391
|
-
};
|
|
392
|
-
TestClass.isPollingStepFlag = "isPollingStep";
|
|
393
|
-
return TestClass;
|
|
394
|
-
}());
|
|
395
|
-
export { TestClass };
|
|
396
|
-
//# sourceMappingURL=TestClass.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestClass.js.map","sources":["TestClass.js"],"sourcesContent":["import dynamicProto from '@microsoft/dynamicproto-js';\r\nimport * as sinon from 'sinon';\r\nimport ESPromise from '../src/ESPromise';\r\nimport { arrForEach, objKeys } from '@microsoft/applicationinsights-core-js';\r\n/** Defines a test case */\r\nvar TestCase = /** @class */ (function () {\r\n function TestCase() {\r\n }\r\n return TestCase;\r\n}());\r\nexport { TestCase };\r\nvar TestClass = /** @class */ (function () {\r\n function TestClass(name) {\r\n /** Turns on/off sinon's fake implementation of XMLHttpRequest. On by default. */\r\n this.sandboxConfig = {};\r\n this._xhrRequests = [];\r\n this._clock = null;\r\n this._beaconHooks = [];\r\n this._dynProtoOpts = null;\r\n QUnit.module(name);\r\n this.sandboxConfig.injectInto = null;\r\n this.sandboxConfig.properties = [\"spy\", \"stub\", \"mock\", \"sandbox\"];\r\n }\r\n /** Method called before the start of each test method */\r\n TestClass.prototype.testInitialize = function () {\r\n };\r\n /** Method called after each test method has completed */\r\n TestClass.prototype.testCleanup = function () {\r\n };\r\n /** Method in which test class intances should call this.testCase(...) to register each of this suite's tests. */\r\n TestClass.prototype.registerTests = function () {\r\n };\r\n /** Register an async Javascript unit testcase. */\r\n TestClass.prototype.testCaseAsync = function (testInfo) {\r\n var _this = this;\r\n if (!testInfo.name) {\r\n throw new Error(\"Must specify name in testInfo context in registerTestcase call\");\r\n }\r\n if (isNaN(testInfo.stepDelay)) {\r\n throw new Error(\"Must specify 'stepDelay' period between pre and post\");\r\n }\r\n if (!testInfo.steps) {\r\n throw new Error(\"Must specify 'steps' to take asynchronously\");\r\n }\r\n if (testInfo.autoComplete === undefined) {\r\n testInfo.autoComplete = true;\r\n }\r\n // Create a wrapper around the test method so we can do test initilization and cleanup.\r\n var testMethod = function (assert) {\r\n var done = assert.async();\r\n // Save off the instance of the currently running suite.\r\n TestClass.currentTestClass = _this;\r\n // Save the real clearTimeout (as _testStarting and enable sinon fake timers)\r\n var orgClearTimeout = clearTimeout;\r\n var orgSetTimeout = setTimeout;\r\n TestClass.orgSetTimeout = function (handler, timeout) {\r\n return orgSetTimeout(handler, timeout);\r\n };\r\n TestClass.orgClearTimeout = function (handler) {\r\n orgClearTimeout(handler);\r\n };\r\n if (testInfo.useFakeServer) {\r\n _this._xhr = sinon.useFakeXMLHttpRequest();\r\n _this._xhrRequests = [];\r\n _this._xhr.onCreate = function (xhr) {\r\n _this._xhrRequests.push(xhr);\r\n };\r\n }\r\n if (testInfo.useFakeTimers) {\r\n _this._clock = sinon.useFakeTimers();\r\n }\r\n // Run the test.\r\n try {\r\n var self_1 = _this;\r\n var testComplete_1 = false;\r\n var timeOutTimer_1 = null;\r\n var testDone_1 = function () {\r\n if (timeOutTimer_1) {\r\n orgClearTimeout(timeOutTimer_1);\r\n }\r\n testComplete_1 = true;\r\n // done is QUnit callback indicating the end of the test\r\n self_1._testCompleted();\r\n done();\r\n };\r\n if (testInfo.timeOut !== undefined) {\r\n timeOutTimer_1 = orgSetTimeout(function () {\r\n QUnit.assert.ok(false, \"Test case timed out!\");\r\n testComplete_1 = true;\r\n done();\r\n }, testInfo.timeOut);\r\n }\r\n _this._testStarting();\r\n var steps_1 = testInfo.steps;\r\n var trigger_1 = function () {\r\n // The callback which activates the next test step. \r\n var nextTestStepTrigger = function () {\r\n orgSetTimeout(function () {\r\n trigger_1();\r\n }, testInfo.stepDelay);\r\n };\r\n if (steps_1.length && !testComplete_1) {\r\n var step = steps_1.shift();\r\n // There 2 types of test steps - simple and polling.\r\n // Upon completion of the simple test step the next test step will be called.\r\n // In case of polling test step the next test step is passed to the polling test step, and\r\n // it is responsibility of the polling test step to call the next test step.\r\n try {\r\n if (step) {\r\n if (step[TestClass.isPollingStepFlag]) {\r\n step.call(_this, nextTestStepTrigger);\r\n }\r\n else {\r\n step.call(_this, testDone_1);\r\n nextTestStepTrigger.call(_this);\r\n }\r\n }\r\n }\r\n catch (e) {\r\n QUnit.assert.ok(false, e.toString());\r\n // done is QUnit callback indicating the end of the test\r\n testDone_1();\r\n return;\r\n }\r\n }\r\n else if (!testComplete_1) {\r\n if (testInfo.autoComplete) {\r\n // done is QUnit callback indicating the end of the test\r\n testDone_1();\r\n }\r\n else {\r\n nextTestStepTrigger();\r\n }\r\n }\r\n };\r\n trigger_1();\r\n }\r\n catch (ex) {\r\n QUnit.assert.ok(false, \"Unexpected Exception: \" + ex);\r\n _this._testCompleted(true);\r\n // done is QUnit callback indicating the end of the test\r\n done();\r\n }\r\n };\r\n // Register the test with QUnit\r\n QUnit.test(testInfo.name, testMethod);\r\n };\r\n /** Register a Javascript unit testcase. */\r\n TestClass.prototype.testCase = function (testInfo) {\r\n var _this = this;\r\n if (!testInfo.name) {\r\n throw new Error(\"Must specify name in testInfo context in registerTestcase call\");\r\n }\r\n if (!testInfo.test) {\r\n throw new Error(\"Must specify 'test' method in testInfo context in registerTestcase call\");\r\n }\r\n // Create a wrapper around the test method so we can do test initilization and cleanup.\r\n var testMethod = function (assert) {\r\n var done = assert.async();\r\n // Save off the instance of the currently running suite.\r\n TestClass.currentTestClass = _this;\r\n function _testFinished(failed) {\r\n TestClass.currentTestClass._testCompleted(failed);\r\n done();\r\n }\r\n // Save the real clearTimeout (as _testStarting and enable sinon fake timers)\r\n var orgClearTimeout = clearTimeout;\r\n var orgSetTimeout = setTimeout;\r\n TestClass.orgSetTimeout = function (handler, timeout) {\r\n return orgSetTimeout(handler, timeout);\r\n };\r\n TestClass.orgClearTimeout = function (handler) {\r\n orgClearTimeout(handler);\r\n };\r\n if (testInfo.useFakeServer) {\r\n _this._xhr = sinon.useFakeXMLHttpRequest();\r\n _this._xhrRequests = [];\r\n _this._xhr.onCreate = function (xhr) {\r\n _this._xhrRequests.push(xhr);\r\n };\r\n }\r\n if (testInfo.useFakeTimers) {\r\n _this._clock = sinon.useFakeTimers();\r\n }\r\n // Run the test.\r\n try {\r\n _this._testStarting();\r\n var result = testInfo.test.call(_this);\r\n if (result instanceof ESPromise) {\r\n var promiseTimeout_1 = null;\r\n if (testInfo.skipTimeout !== true) {\r\n var timeout_1 = testInfo.timeout || 5000;\r\n promiseTimeout_1 = setTimeout(function () {\r\n QUnit.assert.ok(false, \"Timeout: Aborting as the Promise returned from the test method did not resolve within \" + timeout_1 + \" ms\");\r\n _testFinished(true);\r\n }, timeout_1);\r\n }\r\n result.then(function () {\r\n promiseTimeout_1 && clearTimeout(promiseTimeout_1);\r\n _testFinished();\r\n }, function (reason) {\r\n promiseTimeout_1 && clearTimeout(promiseTimeout_1);\r\n QUnit.assert.ok(false, \"Returned Promise rejected: \" + reason);\r\n _testFinished(true);\r\n });\r\n }\r\n else {\r\n _testFinished();\r\n }\r\n }\r\n catch (ex) {\r\n QUnit.assert.ok(false, \"Unexpected Exception: \" + ex);\r\n _testFinished(true);\r\n }\r\n };\r\n // Register the test with QUnit\r\n QUnit.test(testInfo.name, testMethod);\r\n };\r\n TestClass.prototype._deleteAllCookies = function () {\r\n var cookies = document.cookie.split(\";\");\r\n for (var i = 0; i < cookies.length; i++) {\r\n var cookie = cookies[i];\r\n var eqPos = cookie.indexOf(\"=\");\r\n var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;\r\n document.cookie = name + \"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/\";\r\n }\r\n };\r\n TestClass.prototype._disableDynProtoBaseFuncs = function () {\r\n var _this = this;\r\n var defOpts = dynamicProto['_dfOpts'];\r\n if (defOpts) {\r\n if (!this._dynProtoOpts) {\r\n // Save the current settings so we can restore them\r\n this._dynProtoOpts = {};\r\n arrForEach(objKeys(defOpts), function (key) {\r\n _this._dynProtoOpts[key] = defOpts[key];\r\n });\r\n }\r\n defOpts.useBaseInst = false;\r\n }\r\n };\r\n /** Called when the test is starting. */\r\n TestClass.prototype._testStarting = function () {\r\n this.sandbox = sinon.createSandbox(this.sandboxConfig);\r\n // Allow the derived class to perform test initialization.\r\n this.testInitialize();\r\n };\r\n /** Called when the test is completed. */\r\n TestClass.prototype._testCompleted = function (failed) {\r\n var _this = this;\r\n if (this._xhr) {\r\n this._xhr.restore();\r\n this._xhr = null;\r\n }\r\n if (this._clock) {\r\n this._clock.restore();\r\n this._clock = null;\r\n }\r\n if (this._orgNavigator) {\r\n this.setNavigator(this._orgNavigator);\r\n this._orgNavigator = null;\r\n }\r\n if (this._dynProtoOpts) {\r\n var defOpts_1 = dynamicProto['_dfOpts'];\r\n arrForEach(objKeys(this._dynProtoOpts), function (key) {\r\n defOpts_1[key] = _this._dynProtoOpts[key];\r\n });\r\n }\r\n this._beaconHooks = [];\r\n this._cleanupAllHooks();\r\n if (failed) {\r\n // Just cleanup the sandbox since the test has already failed.\r\n this.sandbox.restore();\r\n }\r\n else {\r\n // Verify the sandbox and restore.\r\n this.sandbox.verifyAndRestore();\r\n }\r\n this.testCleanup();\r\n // Clear the instance of the currently running suite.\r\n TestClass.currentTestClass = null;\r\n };\r\n TestClass.prototype._removeFuncHooks = function (fn) {\r\n if (typeof fn === \"function\") {\r\n var aiHook = fn[\"_aiHooks\"];\r\n if (aiHook && aiHook.h) {\r\n aiHook.h = [];\r\n }\r\n }\r\n };\r\n TestClass.prototype._removeHooks = function (target) {\r\n var _this = this;\r\n Object.keys(target).forEach(function (name) {\r\n try {\r\n _this._removeFuncHooks(target[name]);\r\n }\r\n catch (e) {\r\n }\r\n });\r\n };\r\n TestClass.prototype._cleanupAllHooks = function () {\r\n this._removeHooks(XMLHttpRequest.prototype);\r\n this._removeHooks(XMLHttpRequest);\r\n this._removeFuncHooks(window.fetch);\r\n };\r\n TestClass.prototype.spy = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return null;\r\n };\r\n TestClass.prototype.stub = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return null;\r\n };\r\n /** Creates a mock for the provided object.Does not change the object, but returns a mock object to set expectations on the object's methods. */\r\n TestClass.prototype.mock = function (object) { return null; };\r\n /**** end: Sinon methods and properties ***/\r\n TestClass.prototype.setUserAgent = function (userAgent) {\r\n // Hook Send beacon which also mocks navigator\r\n this.hookSendBeacon(null);\r\n Object.defineProperty(window.navigator, 'userAgent', {\r\n configurable: true,\r\n get: function () {\r\n return userAgent;\r\n }\r\n });\r\n };\r\n TestClass.prototype.hookSendBeacon = function (cb) {\r\n var _this = this;\r\n if (!this._orgNavigator) {\r\n var newNavigator = {};\r\n this._orgNavigator = window.navigator;\r\n newNavigator.sendBeacon = function (url, body) {\r\n _this._beaconHooks.forEach(function (element) {\r\n element(url, body);\r\n });\r\n return _this._orgNavigator.sendBeacon(url, body);\r\n };\r\n var _loop_1 = function (name_1) {\r\n if (!newNavigator.hasOwnProperty(name_1)) {\r\n newNavigator[name_1] = navigator[name_1];\r\n if (!newNavigator.hasOwnProperty(name_1)) {\r\n // if it couldn't be set directly try and pretend\r\n Object.defineProperty(newNavigator, name_1, {\r\n configurable: true,\r\n get: function () {\r\n return navigator[name_1];\r\n }\r\n });\r\n }\r\n }\r\n };\r\n // Just Blindly copy the properties over\r\n // tslint:disable-next-line: forin\r\n for (var name_1 in navigator) {\r\n _loop_1(name_1);\r\n }\r\n this.setNavigator(newNavigator);\r\n }\r\n this._beaconHooks.push(cb);\r\n };\r\n TestClass.prototype.setNavigator = function (newNavigator) {\r\n Object.defineProperty(window, 'navigator', {\r\n configurable: true,\r\n get: function () {\r\n return newNavigator;\r\n }\r\n });\r\n };\r\n /**\r\n * Sends a JSON response to the provided request.\r\n * @param request The request to respond to.\r\n * @param data Data to respond with.\r\n * @param errorCode Optional error code to send with the request, default is 200\r\n */\r\n TestClass.prototype.sendJsonResponse = function (request, data, errorCode) {\r\n if (errorCode === undefined) {\r\n errorCode = 200;\r\n }\r\n request.respond(errorCode, { \"Content-Type\": \"application/json\" }, JSON.stringify(data));\r\n };\r\n TestClass.isPollingStepFlag = \"isPollingStep\";\r\n return TestClass;\r\n}());\r\nexport { TestClass };\r\n//# sourceMappingURL=TestClass.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IExtendedTelemetryItem } from '../src/DataModels';
|
|
2
|
-
export declare class TestHelper {
|
|
3
|
-
private static _idCount;
|
|
4
|
-
static reset(key: string): void;
|
|
5
|
-
static mockEvent(persistence: number): IExtendedTelemetryItem;
|
|
6
|
-
static mockEvent2(persistence: number): IExtendedTelemetryItem;
|
|
7
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* 1DS JS SDK Core, 3.1.3
|
|
3
|
-
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
-
* (Microsoft Internal Only)
|
|
5
|
-
*/
|
|
6
|
-
var TestHelper = /** @class */ (function () {
|
|
7
|
-
function TestHelper() {
|
|
8
|
-
}
|
|
9
|
-
TestHelper.reset = function (key) {
|
|
10
|
-
this._idCount = 0;
|
|
11
|
-
localStorage.removeItem(key);
|
|
12
|
-
};
|
|
13
|
-
TestHelper.mockEvent = function (persistence) {
|
|
14
|
-
this._idCount++;
|
|
15
|
-
return {
|
|
16
|
-
name: 'test_event-' + this._idCount.toString(),
|
|
17
|
-
baseType: 'custom',
|
|
18
|
-
time: '',
|
|
19
|
-
persistence: persistence,
|
|
20
|
-
data: {
|
|
21
|
-
'key': 'value',
|
|
22
|
-
empty: [],
|
|
23
|
-
value1: [1],
|
|
24
|
-
value2: ['Hello'],
|
|
25
|
-
value3: [['Hello']],
|
|
26
|
-
value4: true,
|
|
27
|
-
value5: 42,
|
|
28
|
-
value6: {
|
|
29
|
-
more: {
|
|
30
|
-
data: 'X'
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
evValue1: {
|
|
34
|
-
value: 'event Property'
|
|
35
|
-
},
|
|
36
|
-
evValue2: {
|
|
37
|
-
value: 'event Property2',
|
|
38
|
-
kind: 32 /* CustomerContent_GenericContent */,
|
|
39
|
-
propertyType: 1 /* String */
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
TestHelper.mockEvent2 = function (persistence) {
|
|
45
|
-
this._idCount++;
|
|
46
|
-
return {
|
|
47
|
-
name: 'test_event-' + this._idCount.toString(),
|
|
48
|
-
time: ' 1970-01-01T00:00:00.000Z',
|
|
49
|
-
ver: '4.0',
|
|
50
|
-
iKey: 'o:12345-12345',
|
|
51
|
-
ext: {
|
|
52
|
-
sdk: {
|
|
53
|
-
ver: 'Hello version 1.0',
|
|
54
|
-
seq: 1,
|
|
55
|
-
epoch: '0',
|
|
56
|
-
installId: 'TestDeviceId'
|
|
57
|
-
},
|
|
58
|
-
app: { sesId: '####' },
|
|
59
|
-
user: { locale: 'en-US' },
|
|
60
|
-
web: { domain: 'localhost' },
|
|
61
|
-
intweb: {},
|
|
62
|
-
utc: { popSample: 100 },
|
|
63
|
-
loc: { tz: '-08:00' },
|
|
64
|
-
metadata: {
|
|
65
|
-
f: {
|
|
66
|
-
value1: { a: { t: 6 } },
|
|
67
|
-
value5: { t: 6 },
|
|
68
|
-
evValue2: { t: 8193 }
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
baseData: {
|
|
73
|
-
properties: {
|
|
74
|
-
version: '##currentPluginVersions##'
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
data: {
|
|
78
|
-
baseType: 'testEventBaseType',
|
|
79
|
-
value1: [1],
|
|
80
|
-
value2: ['Hello'],
|
|
81
|
-
value3: [['Hello']],
|
|
82
|
-
value4: true,
|
|
83
|
-
value5: 42,
|
|
84
|
-
value6: {
|
|
85
|
-
more: {
|
|
86
|
-
data: 'X'
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
evValue1: 'event Property',
|
|
90
|
-
evValue2: 'event Property2'
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
TestHelper._idCount = 0;
|
|
95
|
-
return TestHelper;
|
|
96
|
-
}());
|
|
97
|
-
export { TestHelper };
|
|
98
|
-
//# sourceMappingURL=TestHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestHelper.js.map","sources":["TestHelper.js"],"sourcesContent":["var TestHelper = /** @class */ (function () {\r\n function TestHelper() {\r\n }\r\n TestHelper.reset = function (key) {\r\n this._idCount = 0;\r\n localStorage.removeItem(key);\r\n };\r\n TestHelper.mockEvent = function (persistence) {\r\n this._idCount++;\r\n return {\r\n name: 'test_event-' + this._idCount.toString(),\r\n baseType: 'custom',\r\n time: '',\r\n persistence: persistence,\r\n data: {\r\n 'key': 'value',\r\n empty: [],\r\n value1: [1],\r\n value2: ['Hello'],\r\n value3: [['Hello']],\r\n value4: true,\r\n value5: 42,\r\n value6: {\r\n more: {\r\n data: 'X'\r\n }\r\n },\r\n evValue1: {\r\n value: 'event Property'\r\n },\r\n evValue2: {\r\n value: 'event Property2',\r\n kind: 32 /* CustomerContent_GenericContent */,\r\n propertyType: 1 /* String */\r\n }\r\n }\r\n };\r\n };\r\n TestHelper.mockEvent2 = function (persistence) {\r\n this._idCount++;\r\n return {\r\n name: 'test_event-' + this._idCount.toString(),\r\n time: ' 1970-01-01T00:00:00.000Z',\r\n ver: '4.0',\r\n iKey: 'o:12345-12345',\r\n ext: {\r\n sdk: {\r\n ver: 'Hello version 1.0',\r\n seq: 1,\r\n epoch: '0',\r\n installId: 'TestDeviceId'\r\n },\r\n app: { sesId: '####' },\r\n user: { locale: 'en-US' },\r\n web: { domain: 'localhost' },\r\n intweb: {},\r\n utc: { popSample: 100 },\r\n loc: { tz: '-08:00' },\r\n metadata: {\r\n f: {\r\n value1: { a: { t: 6 } },\r\n value5: { t: 6 },\r\n evValue2: { t: 8193 }\r\n }\r\n }\r\n },\r\n baseData: {\r\n properties: {\r\n version: '##currentPluginVersions##'\r\n }\r\n },\r\n data: {\r\n baseType: 'testEventBaseType',\r\n value1: [1],\r\n value2: ['Hello'],\r\n value3: [['Hello']],\r\n value4: true,\r\n value5: 42,\r\n value6: {\r\n more: {\r\n data: 'X'\r\n }\r\n },\r\n evValue1: 'event Property',\r\n evValue2: 'event Property2'\r\n }\r\n };\r\n };\r\n TestHelper._idCount = 0;\r\n return TestHelper;\r\n}());\r\nexport { TestHelper };\r\n//# sourceMappingURL=TestHelper.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|