add test, and fix script
This commit is contained in:
parent
638362df1c
commit
f9d626a499
6 changed files with 653 additions and 73 deletions
54
src/__tests__/unit/OrgMapping.spec.ts
Normal file
54
src/__tests__/unit/OrgMapping.spec.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* Unit tests for move-draft-to-current helper functions
|
||||
*/
|
||||
|
||||
import { OrgIdMapping, AllOrgMappings } from '../../interfaces/OrgMapping';
|
||||
|
||||
// Mock dependencies
|
||||
jest.mock('../../database/data-source', () => ({
|
||||
AppDataSource: {
|
||||
createQueryRunner: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('OrgMapping Interfaces', () => {
|
||||
describe('OrgIdMapping', () => {
|
||||
it('should create a valid OrgIdMapping', () => {
|
||||
const mapping: OrgIdMapping = {
|
||||
byAncestorDNA: new Map(),
|
||||
byDraftId: new Map(),
|
||||
};
|
||||
|
||||
expect(mapping.byAncestorDNA).toBeInstanceOf(Map);
|
||||
expect(mapping.byDraftId).toBeInstanceOf(Map);
|
||||
});
|
||||
|
||||
it('should store and retrieve values correctly', () => {
|
||||
const mapping: OrgIdMapping = {
|
||||
byAncestorDNA: new Map([['dna1', 'id1']]),
|
||||
byDraftId: new Map([['draftId1', 'currentId1']]),
|
||||
};
|
||||
|
||||
expect(mapping.byAncestorDNA.get('dna1')).toBe('id1');
|
||||
expect(mapping.byDraftId.get('draftId1')).toBe('currentId1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('AllOrgMappings', () => {
|
||||
it('should create a valid AllOrgMappings', () => {
|
||||
const mappings: AllOrgMappings = {
|
||||
orgRoot: { byAncestorDNA: new Map(), byDraftId: new Map() },
|
||||
orgChild1: { byAncestorDNA: new Map(), byDraftId: new Map() },
|
||||
orgChild2: { byAncestorDNA: new Map(), byDraftId: new Map() },
|
||||
orgChild3: { byAncestorDNA: new Map(), byDraftId: new Map() },
|
||||
orgChild4: { byAncestorDNA: new Map(), byDraftId: new Map() },
|
||||
};
|
||||
|
||||
expect(mappings.orgRoot).toBeDefined();
|
||||
expect(mappings.orgChild1).toBeDefined();
|
||||
expect(mappings.orgChild2).toBeDefined();
|
||||
expect(mappings.orgChild3).toBeDefined();
|
||||
expect(mappings.orgChild4).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue