fix(tracker): update tests for conditionsManager.test.ts
This commit is contained in:
parent
5674f5b9b7
commit
932aa485df
2 changed files with 21 additions and 9 deletions
|
|
@ -667,9 +667,9 @@ export default class App {
|
|||
timezone: getTimezone(),
|
||||
}),
|
||||
})
|
||||
// this token is needed to fetch conditions and flags,
|
||||
// but it can't be used to record a session
|
||||
const {
|
||||
// this token is needed to fetch conditions and flags,
|
||||
// but it can't be used to record a session
|
||||
token,
|
||||
userBrowser,
|
||||
userCity,
|
||||
|
|
@ -714,11 +714,9 @@ export default class App {
|
|||
this.session.applySessionHash(startOpts.sessionHash)
|
||||
}
|
||||
if (startOpts.forceNew) {
|
||||
// Reset session metadata only if requested directly
|
||||
this.session.reset()
|
||||
}
|
||||
this.session.assign({
|
||||
// MBTODO: maybe it would make sense to `forceNew` if the `userID` was changed
|
||||
userID: startOpts.userID,
|
||||
metadata: startOpts.metadata,
|
||||
})
|
||||
|
|
@ -764,11 +762,9 @@ export default class App {
|
|||
this.session.applySessionHash(startOpts.sessionHash)
|
||||
}
|
||||
if (startOpts.forceNew) {
|
||||
// Reset session metadata only if requested directly
|
||||
this.session.reset()
|
||||
}
|
||||
this.session.assign({
|
||||
// MBTODO: maybe it would make sense to `forceNew` if the `userID` was changed
|
||||
userID: startOpts.userID,
|
||||
metadata: startOpts.metadata,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -150,8 +150,24 @@ describe('ConditionsManager', () => {
|
|||
test('processMessage correctly processes a NetworkRequest message', () => {
|
||||
const manager = new ConditionsManager(appMock, startOptionsMock)
|
||||
manager.setConditions([
|
||||
{ type: 'network_request', key: 'url', operator: 'is', value: ['https://api.example.com'] },
|
||||
{ type: 'network_request', key: 'status', operator: 'greaterThan', value: 200 },
|
||||
{
|
||||
type: 'network_request',
|
||||
subConditions: [
|
||||
{ type: 'network_request', key: 'status', operator: 'greaterThan', value: 200 },
|
||||
{
|
||||
type: 'network_request',
|
||||
key: 'url',
|
||||
operator: 'is',
|
||||
value: ['https://api.example.com'],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'network_request',
|
||||
subConditions: [
|
||||
{ type: 'network_request', key: 'status', operator: 'greaterOrEqual', value: 400 },
|
||||
],
|
||||
},
|
||||
])
|
||||
const networkRequestMessage = [
|
||||
Type.NetworkRequest,
|
||||
|
|
@ -160,7 +176,7 @@ describe('ConditionsManager', () => {
|
|||
'https://api.example.com',
|
||||
'Request',
|
||||
'Response',
|
||||
200,
|
||||
201,
|
||||
Date.now(),
|
||||
4000,
|
||||
1024,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue