1414 * limitations under the License.
1515 */
1616import { describe , it , expect , beforeEach , afterEach , vi , assert , Mock } from 'vitest' ;
17- import { forEach , cloneDeep } from 'lodash' ;
1817import { sprintf } from '../utils/fns' ;
19- import fns from '../utils/fns' ;
18+ import { keyBy } from '../utils/fns' ;
2019import projectConfig , { ProjectConfig } from './project_config' ;
2120import { FEATURE_VARIABLE_TYPES , LOG_LEVEL } from '../utils/enums' ;
2221import testDatafile from '../tests/test_data' ;
@@ -42,6 +41,7 @@ const createLogger = (...args: any) => ({
4241} ) ;
4342
4443const buildLogMessageFromArgs = ( args : any [ ] ) => sprintf ( args [ 1 ] , ...args . splice ( 2 ) ) ;
44+ const cloneDeep = ( obj : any ) => JSON . parse ( JSON . stringify ( obj ) ) ;
4545const logger = createLogger ( ) ;
4646
4747describe ( 'createProjectConfig' , ( ) => {
@@ -51,7 +51,7 @@ describe('createProjectConfig', () => {
5151 const testData : Record < string , any > = testDatafile . getTestProjectConfig ( ) ;
5252 configObj = projectConfig . createProjectConfig ( testData as JSON ) ;
5353
54- forEach ( testData . audiences , ( audience : any ) => {
54+ testData . audiences . forEach ( ( audience : any ) => {
5555 audience . conditions = JSON . parse ( audience . conditions ) ;
5656 } ) ;
5757
@@ -64,7 +64,7 @@ describe('createProjectConfig', () => {
6464 testData . groups . forEach ( ( group : any ) => {
6565 group . experiments . forEach ( ( experiment : any ) => {
6666 experiment . groupId = group . id ;
67- experiment . variationKeyMap = fns . keyBy ( experiment . variations , 'key' ) ;
67+ experiment . variationKeyMap = keyBy ( experiment . variations , 'key' ) ;
6868 } ) ;
6969 } ) ;
7070
@@ -78,16 +78,16 @@ describe('createProjectConfig', () => {
7878 expect ( configObj . groupIdMap ) . toEqual ( expectedGroupIdMap ) ;
7979
8080 const expectedExperiments = testData . experiments . slice ( ) ;
81- forEach ( configObj . groupIdMap , ( group : any , groupId : any ) => {
82- forEach ( group . experiments , ( experiment : any ) => {
81+
82+ Object . entries ( configObj . groupIdMap ) . forEach ( ( [ groupId , group ] ) => {
83+ group . experiments . forEach ( ( experiment : any ) => {
8384 experiment . groupId = groupId ;
8485 expectedExperiments . push ( experiment ) ;
8586 } ) ;
86- } ) ;
87-
88- forEach ( expectedExperiments , ( experiment : any ) => {
89- experiment . variationKeyMap = fns . keyBy ( experiment . variations , 'key' ) ;
90- } ) ;
87+ } )
88+ expectedExperiments . forEach ( ( experiment : any ) => {
89+ experiment . variationKeyMap = keyBy ( experiment . variations , 'key' ) ;
90+ } )
9191
9292 expect ( configObj . experiments ) . toEqual ( expectedExperiments ) ;
9393
0 commit comments