Skip to content

Commit 50ae30d

Browse files
committed
opti fix
1 parent b69847f commit 50ae30d

File tree

1 file changed

+55
-10
lines changed

1 file changed

+55
-10
lines changed

lib/optimizely/index.tests.js

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4505,6 +4505,15 @@ describe('lib/optimizely', function() {
45054505
});
45064506

45074507
it('should make a decision for feature_test and dispatch an event', function() {
4508+
const { optlyInstance, eventDispatcher } = getOptlyInstance(
4509+
{
4510+
datafileObj: testData.getTestDecideProjectConfig(),
4511+
}
4512+
);
4513+
4514+
const notificationCenter = optlyInstance.notificationCenter;
4515+
sinon.stub(notificationCenter, 'sendNotifications');
4516+
45084517
var flagKey = 'feature_2';
45094518
var expectedVariables = optlyInstance.getAllFeatureVariables(flagKey, userId);
45104519
var user = new OptimizelyUserContext({
@@ -4600,6 +4609,15 @@ describe('lib/optimizely', function() {
46004609
});
46014610

46024611
it('should make a decision and do not dispatch an event with DISABLE_DECISION_EVENT passed in decide options', function() {
4612+
const { optlyInstance, eventDispatcher } = getOptlyInstance(
4613+
{
4614+
datafileObj: testData.getTestDecideProjectConfig(),
4615+
}
4616+
);
4617+
4618+
const notificationCenter = optlyInstance.notificationCenter;
4619+
sinon.stub(notificationCenter, 'sendNotifications');
4620+
46034621
var flagKey = 'feature_2';
46044622
var expectedVariables = optlyInstance.getAllFeatureVariables(flagKey, userId);
46054623
var user = new OptimizelyUserContext({
@@ -4641,6 +4659,15 @@ describe('lib/optimizely', function() {
46414659
});
46424660

46434661
it('should make a decision with excluded variables and do not dispatch an event with DISABLE_DECISION_EVENT and EXCLUDE_VARIABLES passed in decide options', function() {
4662+
const { optlyInstance, eventDispatcher } = getOptlyInstance(
4663+
{
4664+
datafileObj: testData.getTestDecideProjectConfig(),
4665+
}
4666+
);
4667+
4668+
const notificationCenter = optlyInstance.notificationCenter;
4669+
sinon.stub(notificationCenter, 'sendNotifications');
4670+
46444671
var flagKey = 'feature_2';
46454672
var user = new OptimizelyUserContext({
46464673
optimizely: optlyInstance,
@@ -4684,11 +4711,15 @@ describe('lib/optimizely', function() {
46844711
});
46854712

46864713
it('should make a decision for rollout and dispatch an event when sendFlagDecisions is set to true', function() {
4687-
const { optlyInstance, notificationCenter, eventDispatcher } = getOptlyInstance(
4714+
const { optlyInstance, eventDispatcher } = getOptlyInstance(
46884715
{
46894716
datafileObj: testData.getTestDecideProjectConfig(),
46904717
}
4691-
)
4718+
);
4719+
4720+
const notificationCenter = optlyInstance.notificationCenter;
4721+
sinon.stub(notificationCenter, 'sendNotifications');
4722+
46924723
var flagKey = 'feature_1';
46934724
var expectedVariables = optlyInstance.getAllFeatureVariables(flagKey, userId);
46944725
var user = new OptimizelyUserContext({
@@ -4730,11 +4761,14 @@ describe('lib/optimizely', function() {
47304761
});
47314762

47324763
it('should make a decision for rollout and do not dispatch an event when sendFlagDecisions is set to false', function() {
4733-
const { optlyInstance, notificationCenter, eventDispatcher } = getOptlyInstance(
4764+
const { optlyInstance, eventDispatcher } = getOptlyInstance(
47344765
{
47354766
datafileObj: testData.getTestDecideProjectConfig(),
47364767
}
4737-
)
4768+
);
4769+
4770+
const notificationCenter = optlyInstance.notificationCenter;
4771+
sinon.stub(notificationCenter, 'sendNotifications');
47384772

47394773
var newConfig = optlyInstance.projectConfigManager.getConfig();
47404774
newConfig.sendFlagDecisions = false;
@@ -4780,11 +4814,15 @@ describe('lib/optimizely', function() {
47804814
});
47814815

47824816
it('should make a decision when variation is null and dispatch an event', function() {
4783-
const { optlyInstance, notificationCenter, eventDispatcher } = getOptlyInstance(
4817+
const { optlyInstance, eventDispatcher } = getOptlyInstance(
47844818
{
47854819
datafileObj: testData.getTestDecideProjectConfig(),
47864820
}
4787-
)
4821+
);
4822+
4823+
const notificationCenter = optlyInstance.notificationCenter;
4824+
sinon.stub(notificationCenter, 'sendNotifications');
4825+
47884826
var flagKey = 'feature_3';
47894827
var expectedVariables = optlyInstance.getAllFeatureVariables(flagKey, userId);
47904828
var user = new OptimizelyUserContext({
@@ -4828,10 +4866,14 @@ describe('lib/optimizely', function() {
48284866

48294867
describe('with EXCLUDE_VARIABLES flag in default decide options', function() {
48304868
it('should exclude variables in decision object and dispatch an event', function() {
4831-
const { optlyInstance, notificationCenter, eventDispatcher } = getOptlyInstance({
4869+
const { optlyInstance, eventDispatcher } = getOptlyInstance({
48324870
datafileObj: testData.getTestDecideProjectConfig(),
48334871
defaultDecideOptions: [OptimizelyDecideOption.EXCLUDE_VARIABLES],
4834-
})
4872+
});
4873+
4874+
const notificationCenter = optlyInstance.notificationCenter;
4875+
sinon.stub(notificationCenter, 'sendNotifications');
4876+
48354877
var flagKey = 'feature_2';
48364878
var user = new OptimizelyUserContext({
48374879
optimizely: optlyInstance,
@@ -4871,12 +4913,15 @@ describe('lib/optimizely', function() {
48714913
assert.deepEqual(notificationCallArgs, expectedNotificationCallArgs);
48724914
});
48734915

4874-
it.skip('should exclude variables in decision object and do not dispatch an event when DISABLE_DECISION_EVENT is passed in decide options', function() {
4875-
const { optlyInstance, notificationCenter, eventDispatcher } = getOptlyInstance({
4916+
it('should exclude variables in decision object and do not dispatch an event when DISABLE_DECISION_EVENT is passed in decide options', function() {
4917+
const { optlyInstance, eventDispatcher } = getOptlyInstance({
48764918
datafileObj: testData.getTestDecideProjectConfig(),
48774919
defaultDecideOptions: [OptimizelyDecideOption.EXCLUDE_VARIABLES],
48784920
})
48794921

4922+
const notificationCenter = optlyInstance.notificationCenter;
4923+
sinon.stub(notificationCenter, 'sendNotifications');
4924+
48804925
var flagKey = 'feature_2';
48814926
var user = new OptimizelyUserContext({
48824927
optimizely: optlyInstance,

0 commit comments

Comments
 (0)