@@ -30,6 +30,35 @@ export const directoryFixture = {
|
||||
},
|
||||
}
|
||||
describe('department region configuration', () => {
|
||||
it('uses configurable stable region IDs rather than a four-name whitelist', () => {
|
||||
const catalog = [
|
||||
{ id: 'education', name: '国内教育' },
|
||||
{ id: 'west', name: '国外工业Amercia' },
|
||||
]
|
||||
const state = parseOrganization({
|
||||
...directoryFixture,
|
||||
regions: catalog,
|
||||
rules: [{ department_id: 'root', region: 'education' }],
|
||||
view: {
|
||||
...directoryFixture.view,
|
||||
departments: [{ ...directoryFixture.view.departments[0], region: 'education', explicit: true }],
|
||||
regions: { education: 1, west: 0 },
|
||||
unassigned_people: 0,
|
||||
},
|
||||
})
|
||||
expect(state.regions).toEqual(catalog)
|
||||
expect(state.rules[0].region).toBe('education')
|
||||
expect(state.view.regions.education).toBe(1)
|
||||
})
|
||||
|
||||
it('rejects undeclared region counts rather than silently dropping them', () => {
|
||||
expect(() =>
|
||||
parseOrganization({
|
||||
...directoryFixture,
|
||||
view: { ...directoryFixture.view, regions: { ...directoryFixture.view.regions, undeclared: 0 } },
|
||||
})
|
||||
).toThrow()
|
||||
})
|
||||
it('parses an honest dated snapshot without exposing employee identities', () => {
|
||||
const state = parseOrganization(directoryFixture)
|
||||
expect(state.directory_source).toBe('weekly_report_snapshot')
|
||||
|
||||
Reference in New Issue
Block a user