Skip to content

Commit 5b7f342

Browse files
[FSSDK-11034] review fix
1 parent cfa444d commit 5b7f342

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

lib/project_config/project_config.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
* limitations under the License.
1515
*/
1616
import { describe, it, expect, beforeEach, afterEach, vi, assert, Mock } from 'vitest';
17-
import { forEach, cloneDeep } from 'lodash';
1817
import { sprintf } from '../utils/fns';
19-
import fns from '../utils/fns';
18+
import { keyBy } from '../utils/fns';
2019
import projectConfig, { ProjectConfig } from './project_config';
2120
import { FEATURE_VARIABLE_TYPES, LOG_LEVEL } from '../utils/enums';
2221
import testDatafile from '../tests/test_data';
@@ -42,6 +41,7 @@ const createLogger = (...args: any) => ({
4241
});
4342

4443
const buildLogMessageFromArgs = (args: any[]) => sprintf(args[1], ...args.splice(2));
44+
const cloneDeep = (obj: any) => JSON.parse(JSON.stringify(obj));
4545
const logger = createLogger();
4646

4747
describe('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

package-lock.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
"@rollup/plugin-commonjs": "^11.0.2",
120120
"@rollup/plugin-node-resolve": "^7.1.1",
121121
"@types/chai": "^4.2.11",
122-
"@types/lodash": "^4.17.15",
123122
"@types/mocha": "^5.2.7",
124123
"@types/nise": "^1.4.0",
125124
"@types/node": "^18.7.18",

0 commit comments

Comments
 (0)