Skip to content

Commit de99436

Browse files
committed
fix more tests
1 parent c406523 commit de99436

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lib/optimizely/index.tests.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { createNotificationCenter } from '../core/notification_center';
4040
import { createHttpPollingDatafileManager } from '../plugins/datafile_manager/http_polling_datafile_manager';
4141
import { NodeOdpManager } from '../plugins/odp_manager/index.node';
4242
import { createProjectConfig } from '../core/project_config';
43+
import { get } from 'lodash';
4344

4445
var ERROR_MESSAGES = enums.ERROR_MESSAGES;
4546
var LOG_LEVEL = enums.LOG_LEVEL;
@@ -6800,10 +6801,7 @@ describe('lib/optimizely', function() {
68006801
it('returns an empty array if the instance is invalid', function() {
68016802
optlyInstance = new Optimizely({
68026803
clientEngine: 'node-sdk',
6803-
datafile: {
6804-
lasers: 300,
6805-
message: 'this is not a valid datafile',
6806-
},
6804+
projectConfigManager: getMockProjectConfigManager(),
68076805
errorHandler: errorHandler,
68086806
eventDispatcher: eventDispatcher,
68096807
jsonSchemaValidator: jsonSchemaValidator,
@@ -6841,9 +6839,15 @@ describe('lib/optimizely', function() {
68416839
});
68426840

68436841
it('return features that are enabled for the user and send notification for every feature', function() {
6842+
const mockConfigManager = getMockProjectConfigManager();
6843+
const datafile = testData.getTestProjectConfigWithFeatures();
6844+
6845+
mockConfigManager.setConfig(
6846+
createProjectConfig(datafile, JSON.stringify(datafile)));
6847+
68446848
optlyInstance = new Optimizely({
68456849
clientEngine: 'node-sdk',
6846-
datafile: testData.getTestProjectConfigWithFeatures(),
6850+
projectConfigManager: mockConfigManager,
68476851
errorHandler: errorHandler,
68486852
eventDispatcher: eventDispatcher,
68496853
jsonSchemaValidator: jsonSchemaValidator,
@@ -8921,7 +8925,7 @@ describe('lib/optimizely', function() {
89218925

89228926
it('returns null from getFeatureVariable when optimizely object is not a valid instance', function() {
89238927
var instance = new Optimizely({
8924-
datafile: {},
8928+
projectConfigManager: getMockProjectConfigManager(),
89258929
errorHandler: errorHandler,
89268930
eventDispatcher: eventDispatcher,
89278931
logger: createdLogger,
@@ -8940,7 +8944,7 @@ describe('lib/optimizely', function() {
89408944

89418945
it('returns null from getFeatureVariableBoolean when optimizely object is not a valid instance', function() {
89428946
var instance = new Optimizely({
8943-
datafile: {},
8947+
projectConfigManager: getMockProjectConfigManager(),
89448948
errorHandler: errorHandler,
89458949
eventDispatcher: eventDispatcher,
89468950
logger: createdLogger,
@@ -8959,7 +8963,7 @@ describe('lib/optimizely', function() {
89598963

89608964
it('returns null from getFeatureVariableDouble when optimizely object is not a valid instance', function() {
89618965
var instance = new Optimizely({
8962-
datafile: {},
8966+
projectConfigManager: getMockProjectConfigManager(),
89638967
errorHandler: errorHandler,
89648968
eventDispatcher: eventDispatcher,
89658969
logger: createdLogger,
@@ -8978,7 +8982,7 @@ describe('lib/optimizely', function() {
89788982

89798983
it('returns null from getFeatureVariableInteger when optimizely object is not a valid instance', function() {
89808984
var instance = new Optimizely({
8981-
datafile: {},
8985+
projectConfigManager: getMockProjectConfigManager(),
89828986
errorHandler: errorHandler,
89838987
eventDispatcher: eventDispatcher,
89848988
logger: createdLogger,
@@ -8997,7 +9001,7 @@ describe('lib/optimizely', function() {
89979001

89989002
it('returns null from getFeatureVariableString when optimizely object is not a valid instance', function() {
89999003
var instance = new Optimizely({
9000-
datafile: {},
9004+
projectConfigManager: getMockProjectConfigManager(),
90019005
errorHandler: errorHandler,
90029006
eventDispatcher: eventDispatcher,
90039007
logger: createdLogger,
@@ -9016,7 +9020,7 @@ describe('lib/optimizely', function() {
90169020

90179021
it('returns null from getFeatureVariableJSON when optimizely object is not a valid instance', function() {
90189022
var instance = new Optimizely({
9019-
datafile: {},
9023+
projectConfigManager: getMockProjectConfigManager(),
90209024
errorHandler: errorHandler,
90219025
eventDispatcher: eventDispatcher,
90229026
logger: createdLogger,

0 commit comments

Comments
 (0)