Skip to content

Commit cd6b6b6

Browse files
committed
Dependency: Added unit test for substituting dependsOn uuid
1 parent a416f31 commit cd6b6b6

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/app/model/activity-store.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ describe('ActivityStore', () => {
3535
expect(store.getActivityByUuid('00000000-1111-1111-1111-000000000000')?.name).toBe('Activity 111');
3636
expect(store.getActivityByName('Activity 111')?.level).toBe(1);
3737
expect(store.getActivityByName('Activity 121')?.uuid).toBe('00000000-1111-2222-1111-000000000000');
38+
expect(store.getActivityByName('Activity 112')?.dependsOn).toContain('Activity 111');
39+
expect(store.getActivityByName('Activity 112')?.dependsOn).toContain('Activity 121'); // Substituted uuid
3840
expect(store.getActivities('Dimension 11', 1)).toHaveSize(2);
3941
expect(store.getActivities('Dimension 11', 1)?.map(a => a.name)).toContain('Activity 112');
4042
});

src/app/model/activity-store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export class ActivityStore {
123123
this._activityByName = {};
124124
this._activityByUuid = {};
125125
this.buildLookups(this._activityList, this._activityByName, this._activityByUuid, errors);
126-
this.replaceDependsOnUUids(this._activityList, this._activityByUuid);
127126
}
127+
this.replaceDependsOnUUids(this._activityList, this._activityByUuid);
128128
this.buildDataHierarchy(this._activityList);
129129
this.buildDimensionList(this._activityList);
130130
}
@@ -257,6 +257,7 @@ export class ActivityStore {
257257
for (let i = 0; i < activity.dependsOn.length; i++) {
258258
if (activity.dependsOn[i].match(UUID)) {
259259
if (activityByUuid.hasOwnProperty(activity.dependsOn[i])) {
260+
console.log(`Replaces ${activity.dependsOn[i]} with ${activityByUuid[activity.dependsOn[i]].name}`);
260261
activity.dependsOn[i] = activityByUuid[activity.dependsOn[i]].name;
261262
}
262263
}

src/app/service/loader/data-loader.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export class LoaderService {
2020

2121
constructor(private yamlService: YamlService) {}
2222

23+
get datastore(): DataStore | null {
24+
return this.dataStore;
25+
}
26+
2327
public async load(): Promise<DataStore> {
2428
// Return cached data if available
2529
if (this.dataStore) {

0 commit comments

Comments
 (0)