-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove unused functions in orgUnit module (#290)
These functions were leftover after the OrgUnitDimension was moved to d2-ui-analytics. Because files were renamed,, it's a little difficult to see what I actually changed. This is what has changed: renamed file orgUnitDimensions.js to orgUnit.js renamed "removeOrgUnitLastPathSegment" to "removeLastPathSegment" deleted all functions from orgUnit.js that were not imported anywhere deleted all tests for removed functions
- Loading branch information
1 parent
d118422
commit 556e5b3
Showing
6 changed files
with
130 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { getOrgUnitsFromIds, removeLastPathSegment } from '../orgUnit'; | ||
|
||
describe('getOrgUnitsFromIds', () => { | ||
it('returns org units with ids in given array', () => { | ||
const ids = ['ID1', 'ID2', 'LEVEL-LEVEL', 'GROUP-GROUP_ID']; | ||
const metadata = { | ||
ID1: { | ||
id: 'ID1', | ||
name: 'Org unit 1', | ||
path: '/ID1', | ||
}, | ||
ID2: { | ||
id: 'ID2', | ||
name: 'Org unit 2', | ||
path: '/ID2', | ||
}, | ||
}; | ||
const parentGraphMap = {}; | ||
|
||
const orgUnits = getOrgUnitsFromIds(ids, metadata, parentGraphMap); | ||
|
||
// test that it only extracts org units, not levels/groups | ||
expect(orgUnits.length).toEqual(2); | ||
|
||
orgUnits.forEach(orgUnit => { | ||
expect(orgUnit.id).toEqual(metadata[orgUnit.id].id); | ||
expect(orgUnit.name).toEqual(metadata[orgUnit.id].name); | ||
expect(orgUnit.path).toEqual(metadata[orgUnit.id].path); | ||
}); | ||
}); | ||
|
||
it('returns empty array if there no org units in ou dimension', () => { | ||
const ids = []; | ||
const metadata = {}; | ||
const parentGraphMap = {}; | ||
|
||
expect(getOrgUnitsFromIds(ids, metadata, parentGraphMap)).toEqual([]); | ||
}); | ||
|
||
it('only extracts org unit ids, not groups/levels', () => { | ||
const levelId = 'LEVEL_ID'; | ||
const groupId = 'GROUP_ID'; | ||
|
||
const ids = [`LEVEL-${levelId}`, `GROUP-${groupId}`]; | ||
const metadata = { | ||
[levelId]: { name: 'Level', level: 1 }, | ||
[groupId]: { name: 'Group' }, | ||
}; | ||
const parentGraphMap = {}; | ||
|
||
expect(getOrgUnitsFromIds(ids, metadata, parentGraphMap)).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe('removeLastPathSegment', () => { | ||
it('handles a root path', () => { | ||
const path = '/'; | ||
|
||
expect(removeLastPathSegment(path)).toEqual(path); | ||
}); | ||
|
||
it('handles a path with single segment', () => { | ||
const path = '/abc'; | ||
|
||
expect(removeLastPathSegment(path)).toEqual(path); | ||
}); | ||
|
||
it('handles a path with multiple segments', () => { | ||
const path = 'ABC/def/GHI'; | ||
|
||
expect(removeLastPathSegment(path)).toEqual('ABC/def'); | ||
}); | ||
}); |
Oops, something went wrong.