Skip to content

Commit 0de767e

Browse files
committed
up
1 parent e32b9e1 commit 0de767e

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

lib/core/decision_service/index.spec.ts

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe('DecisionService', () => {
186186
it('should return null if the user does not meet audience conditions', () => {
187187
const user = new OptimizelyUserContext({
188188
optimizely: {} as any,
189-
userId: 'user2'
189+
userId: 'user3'
190190
});
191191

192192
const config = createProjectConfig(cloneDeep(testData));
@@ -197,31 +197,14 @@ describe('DecisionService', () => {
197197

198198
const variation = decisionService.getVariation(config, experiment, user);
199199

200-
expect(variation.result).toBe('variationWithAudience');
201-
expect(mockBucket).not.toHaveBeenCalled();
202-
expect(logger?.debug).toHaveBeenCalledTimes(1);
203-
expect(logger?.info).toHaveBeenCalledTimes(1);
204-
205-
expect(logger?.debug).toHaveBeenNthCalledWith(1, USER_HAS_NO_FORCED_VARIATION, 'user2');
206-
expect(logger?.info).toHaveBeenNthCalledWith(1, USER_FORCED_IN_VARIATION, 'user2', 'variationWithAudience');
207-
208-
user = new OptimizelyUserContext({
209-
shouldIdentifyUser: false,
210-
optimizely: {},
211-
userId: 'user3'
212-
});
213-
experiment = configObj.experimentIdMap['122227'];
214-
assert.isNull(
215-
decisionServiceInstance.getVariation(configObj, experiment, user, { foo: 'bar' }).result
216-
);
217-
218-
assert.deepEqual(mockLogger.debug.args[0], [USER_HAS_NO_FORCED_VARIATION, 'user3']);
200+
expect(variation.result).toBe(null);
219201

220-
assert.deepEqual(mockLogger.debug.args[1], [EVALUATING_AUDIENCES_COMBINED, 'experiment', 'testExperimentWithAudiences', JSON.stringify(["11154"])]);
221202

222-
assert.deepEqual(mockLogger.info.args[0], [AUDIENCE_EVALUATION_RESULT_COMBINED, 'experiment', 'testExperimentWithAudiences', 'FALSE']);
203+
expect(logger?.debug).toHaveBeenNthCalledWith(1, USER_HAS_NO_FORCED_VARIATION, 'user3');
204+
expect(logger?.debug).toHaveBeenNthCalledWith(2, EVALUATING_AUDIENCES_COMBINED, 'experiment', 'testExperimentWithAudiences', JSON.stringify(["11154"]));
223205

224-
assert.deepEqual(mockLogger.info.args[1], [USER_NOT_IN_EXPERIMENT, 'user3', 'testExperimentWithAudiences']);
206+
expect(logger?.info).toHaveBeenNthCalledWith(1, AUDIENCE_EVALUATION_RESULT_COMBINED, 'experiment', 'testExperimentWithAudiences', 'FALSE');
207+
expect(logger?.info).toHaveBeenNthCalledWith(2, USER_NOT_IN_EXPERIMENT, 'user3', 'testExperimentWithAudiences');
225208
});
226209

227210
// it('should return null if the experiment is not running', function() {

0 commit comments

Comments
 (0)