Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | 1x 1x 1x 1x 1x 1x 1x 6x 6x 1x 6x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { TestClass } from '../TestClass'; import * as sinon from 'sinon'; import SessionManager from '../../src/properties/SessionManager'; import Properties from '../../src/properties/Properties'; import { Utils, CoreUtils, IExtendedTelemetryItem } from '@ms/1ds-core-js'; export class PropertiesTest extends TestClass { private sessionManagerStub: sinon.SinonStubbedInstance<SessionManager> | any; private properties: Properties; public testInitialize() { this.sessionManagerStub = sinon.createStubInstance<SessionManager>(SessionManager); this.properties = new Properties(); } public testCleanup() { Utils.deleteCookie('_msei'); } public registerTests() { this.testCase({ name: 'Setup will set the _msei cookie', test: () => { Utils.deleteCookie('_msei'); this.properties.setup(this.sessionManagerStub); QUnit.assert.ok(Utils.getCookie('_msei')); } }); this.testCase({ name: 'Signal will get common properties added', test: () => { this.properties.setup(this.sessionManagerStub); let event: IExtendedTelemetryItem = { name: 'test', time: CoreUtils.toISOString(new Date()), data: { s: { e: {} } } }; this.properties.processTelemetry(event); QUnit.assert.ok(event.data['s']['u']['d']); QUnit.assert.ok(event.data['s']['z']['v']); QUnit.assert.ok(event.data['s']['h']['d']); QUnit.assert.ok(event.data['s']['e']['z']); QUnit.assert.ok(event.data['s']['e']['s'], 'Web'); } }); this.testCase({ name: 'Signal will be passed to session manager to process', test: () => { this.properties.setup(this.sessionManagerStub); let event: IExtendedTelemetryItem = { name: 'test', time: CoreUtils.toISOString(new Date()), data: { s: { e: {} } } }; this.properties.processTelemetry(event); QUnit.assert.ok((this.sessionManagerStub as sinon.SinonStubbedInstance<SessionManager>)._processEvent.calledOnce); } }); this.testCase({ name: 'Signal can be overridden with user fields', test: () => { this.properties.setup(this.sessionManagerStub); this.properties.setUser({ email: 'clippy@msoffice.com', name: 'clippy', localId: 'id', authId: 'orig_clippy', authType: 'MSA' }); let event: IExtendedTelemetryItem = { name: 'test', time: CoreUtils.toISOString(new Date()), data: { s: { e: {} } } }; this.properties.processTelemetry(event); QUnit.assert.equal( event.data['s']['u']['d'], 'id'); QUnit.assert.equal( event.data['s']['u']['a'], 'orig_clippy'); QUnit.assert.equal( event.data['s']['u']['u'], 'MSA'); QUnit.assert.equal( event.data['s']['u']['e'], 'clippy@msoffice.com'); QUnit.assert.equal( event.data['s']['u']['n'], 'clippy'); } }); this.testCase({ name: 'Signal can contain custom properties', test: () => { this.properties.setup(this.sessionManagerStub); this.properties.setProperty('test', 0); let event: IExtendedTelemetryItem = { name: 'test', time: CoreUtils.toISOString(new Date()), data: { s: { e: {} } } }; this.properties.processTelemetry(event); QUnit.assert.equal(event.data['test'], 0); } }); this.testCase({ name: 'Processing the signal removes empty properties', test: () => { this.properties.setup(this.sessionManagerStub); let event: IExtendedTelemetryItem = { name: 'test', time: CoreUtils.toISOString(new Date()), data: { s: { e: {} }, test: '' } }; this.properties.processTelemetry(event); QUnit.assert.notOk(event.data['test']); } }); } } |